You can always put a Script inside of the part and do like this
script.Parent.Touched:connect(function(hit)
local player = game.Players:FindFirstChild(hit.Parent)
if player ~= nil then
if player.PlayerGui:FindFirstChild("Test") then
hit.Parent.Humanoid.Health = 0
else
print("Thing not found, yay")
end
end
end)
A LocalScript will only run Lua code if it is a descendant of one of the following objects:
A Player's Backpack, such as a child of a Tool
A Player's Character model
A Player's PlayerGui
A Player's PlayerScripts
The ReplicatedFirst service
Note: the parent of the LocalScript will determine which client the Lua code will be executed on.
Also, LocalPlayer can only be referenced from the client, via LocalScript. Thus trying to call LocalPlayer anywhere on the server will not work.
More info: http://wiki.roblox.com/index.php?title=API:Class/LocalScript
1 comment
The error does not match this code? Where is 'upvalue'