Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 2 years ago
Edited 2 years ago

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

Log in to vote
0
Answered by 2 years ago

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)
0
Not working because It finds Humanoid when you press One, and the line is above that. GoSeek123 7 — 2y
0
then define humaoid above it. sorry! R_LabradorRetriever 198 — 2y
0
and character and player R_LabradorRetriever 198 — 2y
Ad

Answer this question