Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How To Make Touched Event Only Register One Touch?

I want to register one touch on a part so I can put how many people have touched it on a GUI. Right now, it's registering 2 or 3 parts every time I touch it

local TPWallLeft = script.Parent.Parent.Parent
local Billboard = script.Parent.Parent
local PlayerGUI = script.Parent
local PlayerCount = Instance.new("IntValue")

TPWallLeft.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("HumanoidRootPart") then
		PlayerCount.Value = PlayerCount.Value + 1
	end
end)
wait(15)
print(PlayerCount.Value)

3 comments

0

if u want to do that add a debounce

0

for example when u do a touched add a value restricting more touches , then make a touchended that resets that value easy!

0

thx i cant believe i didnt think of something as simple as that lol

1 answer

TheUltimateTNTFriend solved it: just needed to add debounce lol

This discussion is preserved as it was. New answers, comments, and votes are closed.