Just look at these:
this one is ServerScript service:
local CrouchEvent = Instance.new("RemoteEvent", game.ReplicatedStorage)
CrouchEvent.Name = "CrouchEvent"
local function CrouchAnim(player)
local character = player.Character
if character then
local hum = character:FindFirstChildOfClass("Humanoid")
if hum then
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://12027758629"
local animator = hum:FindFirstChildOfClass("Animator") or Instance.new("Animator")
local animationTrack = animator:LoadAnimation(animation)
animationTrack:Play()
end
end
end
CrouchEvent.OnServerEvent:Connect(CrouchAnim)
this one is the localscript:
local UIS = game:GetService("UserInputService")
local CrouchEvent = game.ReplicatedStorage:WaitForChild("CrouchEvent")
UIS.InputBegan:Connect(function(input, gameProcessedEvent)
if not gameProcessedEvent and input.KeyCode == Enum.KeyCode.C then
CrouchEvent:FireServer()
end
end)