Hello, I am trying to make client to server replication for this running animation, but when I hold shift, it does not run.
Local script:
local UIS = game:GetService('UserInputService')
local Player = game.Players.LocalPlayer
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
script:WaitForChild("RemoteEvent"):FireServer(Player, "true")
end
end)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
script:WaitForChild("RemoteEvent"):FireServer(Player, "false")
end
end)
Server scirpt:
script.Parent.OnServerEvent:Connect(function(plr, running)
local track
local humanoid
if running == "true" then
if plr then
local char = plr.Character or plr.CharacterAdded:Wait()
if char then
humanoid = char:WaitForChild("Humanoid")
if humanoid then
local animator
local success, result = pcall(function()
animator = humanoid:FindFirstChild("Animator")
end)
if not success then
local Animator = Instance.new("Animator")
Animator.Parent = humanoid
end
if humanoid:FindFirstChild("Animator") then
animator = humanoid:FindFirstChild("Animator")
local Animation = Instance.new("Animation")
Animation.AnimationId = 'rbxassetid://9397141402'
track = animator:LoadAnimation(Animation)
track.Looped = true
track:Play()
humanoid.WalkSpeed = 35
end
end
end
end
elseif running == "false" then
track:Stop()
humanoid.WalkSpeed = 16
end
end)
Explorer:
I’ve tried many solutions, they won’t work. Any ideas?