im trying to make an animation play for client and server here is local script in startercharscripts
local TweenService = game:GetService("TweenService")
local Humanoid = game:GetService("Players").LocalPlayer.Character:WaitForChild("Humanoid")
local HumanoidRootPart = game:GetService("Players").LocalPlayer.Character:WaitForChild("HumanoidRootPart")
local CrouchAnimation = game.ReplicatedStorage.CrouchAnimation
local CrouchTrack = Humanoid:LoadAnimation(CrouchAnimation)
local CameraInfo = TweenInfo.new(
0.3,
Enum.EasingStyle.Quint,
Enum.EasingDirection.Out,
0,
false,
0
)
local CrouchedGoal = {CameraOffset = Vector3.new(0,-1.75,0)}
local UncrouchedGoal = {CameraOffset = Vector3.new(0,0,0)}
local CrouchedTween = TweenService:Create(Humanoid, CameraInfo, CrouchedGoal)
local UncrouchedTween = TweenService:Create(Humanoid, CameraInfo, UncrouchedGoal)
local inCrouch = false
local function Crouch()
if inCrouch == false then
inCrouch = true
CrouchedTween:Play()
Humanoid.WalkSpeed = 8
CrouchTrack:Play()
local crouchstart = game.ReplicatedStorage.Remotes.CrouchStart
crouchstart:FireServer(Humanoid)
HumanoidRootPart.CanCollide = false
else
inCrouch = false
UncrouchedTween:Play()
Humanoid.WalkSpeed = 16
CrouchTrack:Stop()
local crouchend = game.ReplicatedStorage.Remotes.Crouchend
crouchend:FireServer(Humanoid)
HumanoidRootPart.CanCollide = true
end
end
game:GetService("UserInputService").InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.C then
Crouch()
end
end)
here is server script in serversciptservice
game.ReplicatedStorage.Remotes.CrouchStart.OnServerEvent:Connect(function(plr)
local CrouchAnimation = game.ReplicatedStorage.CrouchAnimation
local CrouchTrack = plr:FindFirstChild("Humanoid"):LoadAnimation(CrouchAnimation)
CrouchTrack:Play()
end)
game.ReplicatedStorage.Remotes.Crouchend.OnServerEvent:Connect(function(plr)
local CrouchAnimation = game.ReplicatedStorage.CrouchAnimation.AnimationId
local CrouchTrack = plr:FindFirstChild("Humanoid"):LoadAnimation(CrouchAnimation)
CrouchTrack:Stop()
end)```
ServerScriptService.PlayAnims:3: attempt to index nil with âLoadAnimationâ - Server - PlayAnims:3
17:05:16.446 Stack Begin - Studio
17:05:16.447 Script âServerScriptService.PlayAnimsâ, Line 3 - Studio - PlayAnims:3
17:05:16.447 Stack End -