--Script.run.RunAnim.AnimationId = "rbxassetid://7059796563"
--Script.walk.WalkAnim.AnimationId = "rbxassetid://7059797432"
game.ReplicatedStorage.Animate.OnServerEvent:Connect(function(x,Player,Type)
local Script = Player.Character:FindFirstChild("Animate")
if Script then
if Type == "Walking" then
Script.run.RunAnim.AnimationId = "rbxassetid://7059797432"
Script.walk.WalkAnim.AnimationId = "rbxassetid://7059797432"
elseif Type == "Running" then
Script.run.RunAnim.AnimationId = "rbxassetid://7059796563"
Script.walk.WalkAnim.AnimationId = "rbxassetid://7059796563"
end
end
return
end)
game.ReplicatedStorage.ChangeSpeed.OnServerEvent:Connect(function(x,player,speed)
player.Character.Humanoid.WalkSpeed = speed
end)
This script working but not good. It doesn’t switch to the next animation while I’m walking how can i fix
You can detect if the player is running using the humanoid running event. As for walking, the animation will play slower automatically since you are setting it to action and has the whole player playing it. You can read more about the running event here: Humanoid | Roblox Creator Documentation
--Script.run.RunAnim.AnimationId = "rbxassetid://7059796563"
--Script.walk.WalkAnim.AnimationId = "rbxassetid://7059797432"
game.ReplicatedStorage.Animate.OnServerEvent:Connect(function(x,Player,Type)
local Script = Player.Character:FindFirstChild("Animate")
if Script then
if Type == "Walking" then
Script.run.RunAnim.AnimationId = "rbxassetid://7059797432"
Script.walk.WalkAnim.AnimationId = "rbxassetid://7059797432"
elseif Type == "Running" then
Script.run.RunAnim.AnimationId = "rbxassetid://7059796563"
Script.walk.WalkAnim.AnimationId = "rbxassetid://7059796563"
end
end
return
end)
game.ReplicatedStorage.ChangeSpeed.OnServerEvent:Connect(function(x,player,speed)
player.Character.Humanoid.WalkSpeed = speed
end)
--Script.run.RunAnim.AnimationId = "rbxassetid://7059796563"
--Script.walk.WalkAnim.AnimationId = "rbxassetid://7059797432"
local UIS = game:GetService("UserInputService")
local CSEvent = game.ReplicatedStorage.ChangeSpeed
--ONLY EDIT HERE
local runspeed = 20
local walkspeed = 16
--ONLY EDIT HERE
UIS.InputBegan:connect(function(input,gameProcessed)
if input.KeyCode == Enum.KeyCode.LeftShift then
game.ReplicatedStorage.Animate:FireServer(game.Players.LocalPlayer,"Running")
CSEvent:FireServer(game.Players.LocalPlayer,runspeed)
end
end)
UIS.InputEnded:connect(function(input,gameProcessed)
if input.KeyCode == Enum.KeyCode.LeftShift then
game.ReplicatedStorage.Animate:FireServer(game.Players.LocalPlayer,"Walking")
CSEvent:FireServer(game.Players.LocalPlayer,walkspeed,"rbxassetid://7059797432")
end
end)