Recently, I have been having a problem with Tween Service. So when the player touches the Block, another block is supposed to appear (similar to the Custom Duels queueing system). I used a Touched event like you should, but I also used a TouchEnded event for when the player steps off the block. For some reason, the TouchEnded event plays immediately after the Touched event, which isn’t supposed to happen unless the player steps off the block. I used prints to make sure that I was right. Here is the prints and code below.
s1p1.Touched:connect(function(hit)
if not debounce1 then
debounce1 = true
tween1:Play()
print("Tween1")
end
end)
s1p1.TouchEnded:connect(function()
if not deboucne2 then
deboucne2 = true
tween2:Play()
print("Tween2")
end
end)
I hope someone can tell me what went wrong, thanks.
Any limb that touches the part and immediately pulls away (say, a leg that moves due to the walking animation) will trigger both events in quick succession. A decent way of getting around this is to call :GetTouchingParts() on the part when a touch is ended to ensure no part of the character is still touching before running the second tween.
Use a non-CanCollide part that a player can go inside of to detect players entering/leaving the area, instead of a part that’s flat on the ground.
You will also need to deal with TouchEnded firing for each part that stops touching the part!
I have posted about using Touched/TouchEnded in a reliable way elsewhere on the forum, but it might be easier to just :GetTouchingParts() on a loop if you can’t wrap your head around it.