So what I am trying to do is kinda like in a tycoon door. So what I am wanting is where a person can claim a door when it is touched but if the name does not equal to the first name that has touched then it kills them. (Kinda like a tycoon door)
script.Parent.Touched:connect(function(hit) local hum = hit.Parent:FindFirstChild("Humanoid") if hum then local PlayersName = script.Parent:WaitForChild("PlayersName") PlayersName.Value = hit.Parent.Name if hit.Parent.Name ~= PlayersName.Value then hum.Health = hum.Health - 100 end end end)
Assuming PlayersName is a value in the door, you need to check if it's taken before setting it.
script.Parent.Touched:connect(function(hit) local hum = hit.Parent:FindFirstChild("Humanoid") if hum then local PlayersName = script.Parent:WaitForChild("PlayersName") if PlayersName.Value == "" then -- "" being whatever the default value is. PlayersName.Value = hit.Parent.Name elseif hit.Parent.Name ~= PlayersName.Value then hum.Health = 0 end end end)
Hope this helped.