Hi. I am currently working on a game which has a sprinting mechanic. On the client, the animation works fine. However, it does not replicate onto the server.
local plr = game.Players.LocalPlayer
local char = plr.Character
local hum = char.Humanoid
local sprintAnim = hum.Animator:LoadAnimation(script:WaitForChild("Run"))
local TS = game:GetService("TweenService")
local UIS = game:GetService("UserInputService")
local SPRINT_STATE = false
UIS.InputBegan:Connect(function(k,p)
if p then return end
if k.KeyCode == Enum.KeyCode.W then
local currentTime = tick()
if currentTime - LASTPRESS <= EXIT_THRESHOLD then
print("Sprint")
SPRINT_STATE = true
TS:Create(cam,TweenInfo.new(0.4),{ FieldOfView = 85}):Play()
sprintAnim:Play()
hum.WalkSpeed = 26
else
LASTPRESS = currentTime
end
end
end)
UIS.InputEnded:Connect(function(k,p)
if p then return end
if k.KeyCode == Enum.KeyCode.W then
SPRINT_STATE = false
TS:Create(cam,TweenInfo.new(0.4),{ FieldOfView = 70}):Play()
sprintAnim:Stop()
hum.WalkSpeed = 12
end
end)
Location of animations and script
I have been stuck on this issue for quite a while, and have not found any solutions despite seeking help in other dev posts and discord channels.