Hi! I’m trying to make a remastered prison life game, but I’ve got a problem.
When running, the animation on the server is a bit weird. For example:
This is what the client sees.
https://cdn.discordapp.com/attachments/932648931408637993/933519723365269554/2022-01-19_19-33-18.mp4
This is what the server sees.
My state handler:
local RequireService = require(game.ReplicatedStorage.Lib.RequireModule);
repeat
wait(1)
until script.Parent:FindFirstChild("Head")
local Player = RequireService("Players").LocalPlayer;
local UIS = RequireService("UserInputService");
local Animate
local Humanoid = Player.Character:FindFirstChild('Humanoid');
local States = {
["Crouch"] = false;
["Run"] = false;
}
local QueueOnWalk = {}
local Anims = {
["CrouchIdle"] = Humanoid:LoadAnimation(script.CrouchIdle);
["CrouchWalk"] = Humanoid:LoadAnimation(script.CrouchWalk);
["CrouchIdleR6"] = Humanoid:LoadAnimation(script.CrouchIdleR6);
["CrouchWalkR6"] = Humanoid:LoadAnimation(script.CrouchWalkR6);
["Run"] = Humanoid:LoadAnimation(script.Run);
["RunR6"] = Humanoid:LoadAnimation(script.RunR6);
}
local IsR6 = Humanoid.RigType == Enum.HumanoidRigType.R6;
local Char = script.Parent;
-- PC
UIS.InputBegan:Connect(function(Input, Typing)
local IKC = Input.KeyCode;
local KC = Enum.KeyCode;
if IKC == KC.LeftControl then
Char.Animate.idle["Animation1"].AnimationId = Anims.CrouchWalkR6.Animation.AnimationId;
Char.Animate.idle["Animation2"].AnimationId = Anims.CrouchWalkR6.Animation.AnimationId;
Char.Animate.walk.WalkAnim.AnimationId = Anims.CrouchIdleR6.Animation.AnimationId;
Char.Animate.run.RunAnim.AnimationId = Anims.CrouchIdleR6.Animation.AnimationId;
Humanoid:ChangeState(Enum.HumanoidStateType.Landed)
States.Run = false;
States.Crouch = true;
Humanoid.WalkSpeed = 8;
end
if IKC == KC.LeftShift then
Char.Animate.walk.WalkAnim.AnimationId = Anims.RunR6.Animation.AnimationId;
Char.Animate.run.RunAnim.AnimationId = Anims.RunR6.Animation.AnimationId;
--table.insert(QueueOnWalk, "LandedState")
RequireService("TweenService"):Create(workspace.CurrentCamera, TweenInfo.new(.5), {FieldOfView = 90}):Play()
Humanoid:ChangeState(Enum.HumanoidStateType.Landed);
Humanoid.WalkSpeed = 25;
States.Run = true;
end
end)
UIS.InputEnded:Connect(function(Input, Typing)
local IKC = Input.KeyCode;
local KC = Enum.KeyCode;
if IKC == KC.LeftControl then
Char.Animate.idle["Animation1"].AnimationId = "rbxassetid://8420915727"
Char.Animate.idle["Animation2"].AnimationId = "rbxassetid://8420915727"
Char.Animate.walk.WalkAnim.AnimationId = "rbxassetid://8420926467"
Char.Animate.run.RunAnim.AnimationId = "rbxassetid://8420926467"
Humanoid:ChangeState(Enum.HumanoidStateType.Landed);
States.Crouch = false;
if States.Run == true then
Humanoid.WalkSpeed = 25;
else
Humanoid.WalkSpeed = 16;
end
end
if IKC == KC.LeftShift then
Char.Animate.walk.WalkAnim.AnimationId = "rbxassetid://8420926467"
Char.Animate.run.RunAnim.AnimationId = "rbxassetid://8420926467"
--table.insert(QueueOnWalk, "LandedState")
RequireService("TweenService"):Create(workspace.CurrentCamera, TweenInfo.new(.5), {FieldOfView = 70}):Play()
Humanoid:ChangeState(Enum.HumanoidStateType.Landed);
Humanoid.WalkSpeed = 16;
States.Run = true;
end
end)
Humanoid.Running:Connect(function(spd)
if spd > 0 then
-- lol
end
end)
--[[ ignore!!! ]]
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
function animationPlayed(anim)
local name = anim.Name:lower() -- Get the name of the animation in all lowercase, helps with finding the name.
if name == "toolnoneanim" or name:find("tool") then -- "toolnoneanim" is the name of the tool equip animation, if Roblox happens to change the name it'll look for "tool" in the name.
anim:Stop()
end
end
humanoid.AnimationPlayed:Connect(animationPlayed)
I’m trying to get it to stop playing that run animation when the player stops running. Any help?