I want to make it so that once a player touches a part, it no longer responds to touches from that player. Making a general debounce true or false value doesn’t work since that disables the part from any player touching it, so my idea was to create a string value once a player touches it with their name, and have it check for that string value, but I don’t really know how to make it do this.
2 Likes
I prefer handling this on server tables instead of adding values somewhere.
Just, when a player touch the part, add a new entry in the Dictionary using the UserId of the player who touched it, and set it to false, then use that entry to check if player can touch again or not
local TableOfTouches = {}
script.Parent.Touched:Connect(function(hit)
if hit.Name == "HumanoidRootPart" then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
if TableOfTouches[player.UserId] == nil then
TableOfTouches[player.UserId] = false
-- RUN YOUR CODE
warn("First touch")
else
warn("Not allowed to touch again")
end
end
end
end)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.