Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

The animation wont stop when i press "1" How do i fix it?

Im making emote menu but when i press "1" to stop the animation it wont stop.

-- Variables --
local UserInputService = game:GetService("UserInputService")
local Anim1 = script.Emote1

UserInputService.InputBegan:Connect(function(input)
	-- Emote 1 --
	if input.KeyCode == Enum.KeyCode.One then
		local Player = game.Players.LocalPlayer
		local Character = Player.Character
		local Humanoid = Character:WaitForChild("Humanoid")
		local Gui = Player.PlayerGui:WaitForChild("EmoteMenu")
		local Emote1 = Humanoid:LoadAnimation(Anim1)
		if Gui.Main.Visible == true then
			script.EmotePlaying.Value = true
			Gui.Main.Visible = false		game.ReplicatedStorage.EmoteMenu.UsedEmote1:FireServer(game.Players.LocalPlayer)
			Emote1:Play()
			Humanoid.WalkSpeed = 4
			wait(6.7)
			Emote1:Stop()
			Humanoid.WalkSpeed = 26
			script.EmotePlaying.Value = false
			-- Stop Emote
		elseif script.EmotePlaying.Value == true then
			Humanoid.WalkSpeed = 26
			Emote1:Stop()
			script.EmotePlaying.Value = false
			if Character.HumanoidRootPart:FindFirstChild("Sound1") then
				Character.HumanoidRootPart.Sound1:Destroy()
			end
		end
	end
end)

1 answer

✓ Accepted answer

move line twelve up so that ur stopping and playing the same loaded animation. It should work now.

-- Variables --
local UserInputService = game:GetService("UserInputService")
local Anim1 = script.Emote1

local Emote1 = Humanoid:LoadAnimation(Anim1) --here

UserInputService.InputBegan:Connect(function(input)
    -- Emote 1 --
    if input.KeyCode == Enum.KeyCode.One then
        local Player = game.Players.LocalPlayer
        local Character = Player.Character
        local Humanoid = Character:WaitForChild("Humanoid")
        local Gui = Player.PlayerGui:WaitForChild("EmoteMenu")
        --local Emote1 = Humanoid:LoadAnimation(Anim1)
        if Gui.Main.Visible == true then
            script.EmotePlaying.Value = true
            Gui.Main.Visible = false        game.ReplicatedStorage.EmoteMenu.UsedEmote1:FireServer(game.Players.LocalPlayer)
            Emote1:Play()
            Humanoid.WalkSpeed = 4
            wait(6.7)
            Emote1:Stop()
            Humanoid.WalkSpeed = 26
            script.EmotePlaying.Value = false
            -- Stop Emote
        elseif script.EmotePlaying.Value == true then
            Humanoid.WalkSpeed = 26
            Emote1:Stop()
            script.EmotePlaying.Value = false
            if Character.HumanoidRootPart:FindFirstChild("Sound1") then
                Character.HumanoidRootPart.Sound1:Destroy()
            end
        end
    end
end)

3 comments

0

Not working because It finds Humanoid when you press One, and the line is above that.

0

then define humaoid above it. sorry!

0

and character and player

This discussion is preserved as it was. New answers, comments, and votes are closed.