Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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

Log in to vote
0
Answered by 5 years ago

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)
0
still doesn't work i fixed all your Error ImAnonymousBan 24 — 5y
0
still spam print both ImAnonymousBan 24 — 5y
Ad

Answer this question