How I Disconnect A function

i want to disconnect a function but doesn’t work! it doesn’t work:

please help

ps: i fixed the line 26

You need to store the event in a variable (ex. local died = Humanoid.Died:Connect(OnDied) then you can use died:Disconnect().

2 Likes

If you’re wanting the function to stop, I’d suggest creating variable a as true, and while a is true walk, then when the player dies, set a to false

1 Like

but i need it to stop immediatly because i want to stop the slime from walking or going idle

Then OnDied, use :MoveTo() and put in it’s position.

And move the wait to the end of the loop.

this is what happens:
robloxapp-20240114-1855156.wmv (2.6 MB)

Move the wait() to the end of the while loop, then stop both of the animations on the OnDied() event, hope that helps.

i need to go ill’see later ._.