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

help i can't fix this problem using touched and touchendded is it really not working???

Script

local part = script.Parent

part.Touched:Connect(function()
	print("Player is in")
end)

part.TouchEnded:Connect(function()
	print("player is out")
end)

so my problem here is, if i walked in the part it spam print both the touched and touchendded. if i don't walk it doen't print anything, i want it to print once if the player is inside the block. and i want it also to print once if the player is outside the block. after this is solved im going to make map voting. --------//if you can't understand this! im saying is if i walked to the part it spam print the touched and touchendded for some reason. i want it to print once.

1 answer

This should work.Don't hesitate to tell me if you got any errors.

local part = script.Parent
local DebounceEnter = false

part.Touched:Connect(function()
if DebounceEnter == false then
DebounceEnter = true
    print("Player is in")
end)

part.TouchEnded:Connect(function()
if DebouncEnter == true then
DebounceEnter = false
    print("player is out")
end)

2 comments

0

still doesn't work i fixed all your Error

0

still spam print both

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