Touched event not working

Good afternoon!

I was working on a script where if you touch the block, “ObbySpawnPlace”, you would get dialogue. However, the game will not recognize that I have stepped on the part and will just play no matter what. Here’s the script:

script.Parent.Enabled = false



if game.Workspace.ObbySpawnPlace.Touched then
script.Parent.Enabled = true
wait(0.5)
game.Workspace.Talk:Play()
typewrite(textLabel,"Here's my obby, Super Epic Fun 100 level free admin Flamingo Obby. 
Original name, right?")
wait(0.2)
game.Workspace.Talk:Pause()
wait(0.5)
game.Workspace.Talk:Play()
typewrite(textLabel,"Get to the end of my obby for free admin :D")
wait(0.2)
game.Workspace.Talk:Stop()
wait(1)
script.Parent.Enabled = false
end

Please help!

1 Like

Touched is an Event. You can connect functions to events (which makes them run every time it is fired, in this case when the object is touched) by using :Connect(), and the function inside the parenthesis.

Keep in mind that the Touched event fires when it touches any basepart, including non-character parts.

1 Like

I think this should work.

script.Parent.Enabled = false

game.Workspace.ObbySpawnPlace.Touched:Connect(function(Part) 
script.Parent.Enabled = true
wait(0.5)
game.Workspace.Talk:Play()
typewrite(textLabel,"Here's my obby, Super Epic Fun 100 level free admin Flamingo Obby. 
Original name, right?")
wait(0.2)
game.Workspace.Talk:Pause()
wait(0.5)
game.Workspace.Talk:Play()
typewrite(textLabel,"Get to the end of my obby for free admin :D")
wait(0.2)
game.Workspace.Talk:Stop()
wait(1)
script.Parent.Enabled = false
end)

I tried it, but the text is having a stroke whenever I stand on it. Is there a way to stop it from attempting to repeat itself?

You should add a debounce to avoid it from repeating/spamming.