Hello all, I’m trying to come up with a script that allows my character to have a custom walk animation and then when shift toggled, a custom run animation will kick in.
This is what i’ve written so far (local script):
local UIS = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local Humanoid = Players.LocalPlayer.Character.Humanoid
local Animator = Humanoid:WaitForChild("Animator",10)
local WalkAnimation = Instance.new('Animation')
WalkAnimation.AnimationId = "rbxassetid://6075289167"
local LoadWalkAnimation = Animator:LoadAnimation(WalkAnimation)
LoadWalkAnimation.Priority = Enum.AnimationPriority.Movement
local RunAnimation = Instance.new('Animation') --Running Animation
RunAnimation.AnimationId = "rbxassetid://6059811537"
local LoadRunAnimation = Animator:LoadAnimation(RunAnimation)
LoadRunAnimation.Priority = Enum.AnimationPriority.Movement
game.Players.LocalPlayer.CharacterAdded:Connect(function()
LoadWalkAnimation:Play()
end)
UIS.InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.LeftShift then
LoadRunAnimation:Play()
ReplicatedStorage.RemoteEvents.Sprint:FireServer("StartedState")
end
end)
UIS.InputEnded:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.LeftShift then
LoadRunAnimation:Stop()
ReplicatedStorage.RemoteEvents.Sprint:FireServer("EndedState")
end
end)
ReplicatedStorage.RemoteEvents.StaminaUpdate.OnClientEvent:Connect(function(Stamina,MaxStamina)
Players.LocalPlayer.PlayerGui.Stamina.StaminaBar.Size = UDim2.new(0.1,(Stamina/MaxStamina) * 410,0,31)
end)
I have the run animation sorted, just need some guidance on working out the walk animation.