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)

1 comment
Why are you using ReplicatedStorage for this? Animations are replicated across all clients without ReplicatedStorage being used