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

Animation stuck inside character after InputEnded ?

Asked by
ziAce 15
6 years ago

So I created this reduce-damage block kind of script. Animated it sorta and it works but there's a problem. It's made so when I hold the key , it repeats the animation and basically stays up. But when I let go it should stop the animation, destroy it and make me able to walk again. Which works but sometimes it just glitches out and im stuck standing with my arm up not being able to walk. Like the script just left out the InputEnded part completly. I've been trying to solve this for multiple hours without a solution. I really need help guys qq

repeat wait() until game.Players.LocalPlayer.Character

local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Character = Player.Character
local en = true
local ten =  true


UIS.InputBegan:connect(function(input, gameProcessedEvent)
    if input.KeyCode == Enum.KeyCode.Z and en == true then
    en = false
        script.Parent.Parent.Sprint.Disabled = true
        Character.Humanoid.WalkSpeed = 0
        anim = Instance.new("Animation", Character)
        anim.Name = "Raise"
        anim.AnimationId = "rbxassetid://01232354549"
        loadanim = Character.Humanoid:LoadAnimation(anim)
        loadanim:Play()
        Character.Humanoid.Health = 200
     end    
end)         
     UIS.InputEnded:connect(function(input, gameProcessedEvent) 
    if input.KeyCode == Enum.KeyCode.Z and ten == true then
        ten = false
        Character.Humanoid.Health = 100
        Character.Humanoid.WalkSpeed = 16
        loadanim:Stop()
        anim:Remove()
        script.Parent.Parent.Sprint.Disabled = false
        wait(5)
        ten = true
        en = true   
    end 
    end)


Answer this question