GetTagAddEvent
格式
GetTagAddEvent(tagName)
- 函数
- 所属对象:TagService
简介
为给定的tagname注册事件,当某个对象被赋予了给定tag后,获取该事件对象
参数
变量名称 | 类型 | 默认 | 描述 |
---|---|---|---|
tagName | string | 添加标签的名称 |
返回值
类型 | 描述 |
---|---|
EventObject | 标签添加事件的事件对象 |
实例
零件添加标签时设置颜色。
local workSpace=GetService("WorkSpace") --获取工作区服务
local tagService=GetService("TagService") --获取标签服务对象
tagService:GetTagAddEvent("vip"):Connect(function(obj) --被添加vip标签的对象变为红色
obj.Color = Vector3.New(255, 0, 0)
print("添加标签事件触发")
end)
local a = RWObject:New("Part") --创建对象a
a.Name = "a"
a.Position=Vector3.New(-2,1,2)
a.Parent=workSpace
wait(2) --2秒后添加标签
tagService:AddTag(a, "vip") --给a添加vip标签
文档更新时间: 2020-07-11 14:14 作者:王辰剑