[im noob] can anyone help? script should play as soon as humanoid stops moving (if possible then at a given time of not moving)

Ok so Basically i have this script i want inside a tool gun to play an Animation when the player is idle for a while (it does work but not with what i want the script to have)

the script does work but not with the “if-then” thing, i want it to play everytime when the humanoid isnt running.

if script.Parent.Parent.Humanoid.Running false then --faulty or wrong
	debounce = false
	script.Parent.Equipped:Connect(function(Mouse)
    	wait(8)
        	if debounce == false then
            	debounce = true			
            	animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Idle)
            	animation:Play()
            	wait(1.5)
            	debounce = false
        	end
    	end)

	script.Parent.Unequipped:Connect(function()
        animation:Stop()
	end)

	script.Parent.Parent.Humanoid.Running:Connect(function()
	animation:Stop()
	end)
	end 





if possible even input a way to make it only play if it isnt running for a while, anyway help is apreciated.

3 Likes

an if statement runs once so try a different way other then that

1 Like

hmmmm i dont know which tho, i will continue on trying stuff, thanks for tleling me that tho, ima try something else, i dont know what tho, i will try to check

are there any errors i need to know!

1 Like

A non-moving Humanoid will fire Running with a speed of 0.

2 Likes

what does that mean? unless flagged

That just means I deleted my first post because it was wrong. (Deleting a post changes the text to that for an hour.)

2 Likes

yes i know, but thats not where the thing is wrong, that part is working, the thing where it goes wrong is that it only plays the animation once, but i want it to play everytime the player is away for over 14 seconds yk? thats what i tried to do

1 Like

will that play the script multiple times even after it already fired?

1 Like

ok thanks anyway!
ima check it out righ tnow

1 Like

oh yeah i saw it but didnt notice it (wot)
ima check it out

1 Like

“if speed > 0” means if speed exceeds 0 right?

1 Like
debounce = false
	script.Parent.Equipped:Connect(function(Mouse)
	game.Workspace.Player.Humanoid.Running:Connect(function(speed)
    	if speed > 0 then
        	print("Player is running")
    	else

    		wait(8)
        		if debounce == false then
            		debounce = true			
            		animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Idle)
            		animation:Play()
            		wait(1.5)
            		debounce = false
					print('Speer Operator is now Idle!')
				
		script.Parent.Unequipped:Connect(function()
        	animation:Stop()
			print('Speer Unequipped, animation stopped!')
				end)








boi this doesnt work oof, the last “end)” is marked as red and console says:
08:19:17.240 - Workspace.CarlosmaniaLAPTOP.SpeerFire.IdleAnimation:18: Expected identifier when parsing expression, got ‘)’

1 Like

Add another “end)” . It might be because of the amount of brackets. For example, there is not enough of these brackets ( and these brackets ). Or too many brackets.

1 Like

another end at the very end? i tried that and it seems like there is still something wrong, i believe there is a missing “end)” somewhere in the middle of the script

1 Like

oh wait, i got it working it was a missing bracket indeed (at the very bottom), now ima try to test it

1 Like

doesnt work, i think it isnt finding the humanoid running, ima try to add script.parent.humanoid.running

1 Like

A game file so we can actually see where the humanoid and other things are located without you having to explain it. You don’t have to if it has parts of your game that you don’t want to show.

1 Like

only can build the script when playing, ima send you the game file right away just dont reupload it lol

1 Like

No, don’t send it to me
My studio isn’t working like I said before.

2 Likes