【发布时间】:2020-11-23 14:45:27
【问题描述】:
我目前正在为学校作业制作 Roblox 游戏,所以我正在制作一个基本的大亨游戏,其功能如下:
game.Workspace.Gate.Touched:Connect(function()
game.Workspace.Path.Transparency = 0
game.Workspace.Path.CanCollide = true
game.Workspace.Fence.Transparency = 0
game.Workspace.Fence.CanCollide = true
end
但我想知道是否有办法让这个功能从长远来看更实用,使其类似于:
game.Workspace.Gate.Touched:Connect(function({{myVar}})
game.Workspace.{{myVar}}.Transparency = 0
game.Workspace.{{myVar}}.CanCollide = true
end
老实说,我今天才开始使用 Lua,但很快就学会了,但我想我错过了很多东西。 提前致谢。
【问题讨论】:
-
是的:
Parent.Parent[VAR].child -
我建议你使用CollectionService。
标签: lua game-development roblox