I have these two scripts inside an Animation which is in Backpack. The animation and sound plays fine, but when the second script runs, it does not stop the animation but runs everything else.

Play Script:

wait()
local anim = script.Parent
local uis = game:GetService("UserInputService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local char = player.Character
local hum = char:FindFirstChild("Humanoid")
local emoteval = game.Players.LocalPlayer.AnimationFolder.Emote1
local redbone = script.Parent.REDBONE

uis.InputBegan:Connect(function(input,gameProcessed)
	local ann = hum:LoadAnimation(anim)
	if emoteval.Value == false and input.KeyCode == Enum.KeyCode.E then
		
		print("e has been pressed!")
		hum.WalkSpeed = 0
		hum.JumpPower = 0
		wait(0.2)
		redbone:Play()
		emoteval.Value = true
		ann:Play()
	
		
	end
	
end)

Stop Script:

wait()
local anim = script.Parent
local uis = game:GetService("UserInputService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local char = player.Character
local hum = char:FindFirstChild("Humanoid")
local emoteval = game.Players.LocalPlayer.AnimationFolder.Emote1
local redbone = script.Parent.REDBONE

uis.InputBegan:Connect(function(input,gameProcessed)
	local ann = hum:LoadAnimation(anim)
	if emoteval.Value == true and input.KeyCode == Enum.KeyCode.E then
		ann:Stop()
		print("e has been pressed again!")
		hum.WalkSpeed = 16
		hum.JumpPower = 50
		wait(0.2)
		
		
		redbone:Stop()
		emoteval.Value = false
		
		
	end
	
end)


2 comments

0

You don't need two scripts to stop and play an animation. Just have it in one script.

0

Try using it in another game of yours, I also have trouble with animation and script in some games and not others