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

Why are animations not running when i hold T and when I release it?

Asked by
boyoss 2
3 years ago

I'm trying to do that the character makes an animation when we hold T and when we release it make another animation. Here are the codes

this is the local player script

local UIS = game:GetService('UserInputService')


UIS.InputBegan:Connect(function(key)
    if key == Enum.KeyCode.T then
        game.ReplicatedStorage["Enter animation"]:FireServer(6456343893)
    end
end)

UIS.InputEnded:Connect(function(key)
    if key == Enum.KeyCode.T then
        game.ReplicatedStorage["Exit animation"]:FireServer(6453646544)
    end
end)

this is the first animation

game.ReplicatedStorage["Enter animation"].OnServerEvent:Connect(function(player, animationID)
    local animation = Instance.new("Animation")
    animation.AnimationId = "http://www.roblox.com/Asset?ID="..animationID


    local loadedAnimation = game.Workspace[player.Name].Humanoid:LoadAnimation(animation)
    loadedAnimation:Play()

end)

this is the second

game.ReplicatedStorage["Exit animation"].OnServerEvent:Connect(function(player, animationID)
    local animation = Instance.new("Animation")
    animation.AnimationId = "http://www.roblox.com/Asset?ID="..animationID


    local loadedAnimation = game.Workspace[player.Name].Humanoid:LoadAnimation(animation)
    loadedAnimation:Play()

end)
0
Why are you using ReplicatedStorage for this? Animations are replicated across all clients without ReplicatedStorage being used FrancisRUnderwood 0 — 3y

Answer this question