Hi i am making a game and i have a part that is like a button when you stand on it your name will be in a dictionary and when you don’t touch it, it will remove you from the dictionary.
This is the code i have right now
local touched = {}
script.Parent.Touched:Connect(function(touch)
if touch.Parent.HumanoidRootPart then
touched[touch.Parent.Name] = 0
end
end)
script.Parent.TouchEnded:Wait(function(touch)
if touch.Parent.HumanoidRootPart then
touched[touch.Parent.Name] = nil
end
end)
This doesn’t work because when i step on to the button it does add me to the dictionary but shortly after it removes me again while i am still touching it any help?
as far as i know when using something like this in an if statement it should only go the next line if it doesn’t throw an error and that the statement is true
Really? Unless I’m confusing something I think it will say “Attempt to index nil with HumanoidRootPart” but I may be wrong. You could always test and prove me wrong though