Hi, i have a custom animations script for stuff like walking, sprinting, and crouching, however i get the error “failed to load animation, sanitised id” it works for the owner of the game on client testing but not server testing, the animations are uploaded to the group the game is under and has the right priorities.
local Player = game.Players.LocalPlayer
local Hum
local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local DefaultFOV = 85
local WDown = false
local ADown = false
local SDown = false
local DDown = false
local AnimFolder = game.StarterPlayer.StarterCharacterScripts.Animations
local RunSpeed = 15
local WlkSpeed = 8
local CrouchSpeed = 4
Player.CharacterAdded:Wait()
local character = Player.Character
Hum = character:WaitForChild("Humanoid")
local CStart = Hum:LoadAnimation(AnimFolder:WaitForChild("CrouchStart"))
local Walk = Hum:LoadAnimation(AnimFolder:WaitForChild("CrouchWalk")) -- Change "Walk" to the name of your walk animation
local controlPressed = false -- Variable to track if control is pressed
local WalkAnim = Hum:LoadAnimation(AnimFolder:WaitForChild("WalkAnim"))
local RunAnim = Hum:LoadAnimation(AnimFolder:WaitForChild("RunAnim"))
RunAnim.Looped = true
local shiftPressed = false
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftControl then
if WDown then
Walk:Play()
end
if ADown then
Walk:Play()
end
if SDown then
Walk:Play()
end
if DDown then
Walk:Play()
end
controlPressed = true
Hum.WalkSpeed = CrouchSpeed
Hum.JumpPower = 0
CStart:Play()
CStart.Looped = true
RunAnim:Stop()
end
end)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftControl then
controlPressed = false
Hum.WalkSpeed = WlkSpeed
Hum.JumpPower = 50
CStart:Stop()
Walk:Stop()
end
end)
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.W and controlPressed then
-- If control is pressed and the player starts walking
CStart:Stop() -- Stop CrouchStart animation
Walk:Play()
Walk.Looped = true-- Play the walk animation
end
end)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.W then
-- If the player stops walking
Walk:Stop() -- Stop the walk animation
if controlPressed then
CStart:Play() -- If control is pressed, play CrouchStart animation again
end
end
end)
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.A and controlPressed then
-- If control is pressed and the player starts walking
CStart:Stop() -- Stop CrouchStart animation
Walk:Play()
Walk.Looped = true-- Play the walk animation
end
end)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.A then
-- If the player stops walking
Walk:Stop() -- Stop the walk animation
if controlPressed then
CStart:Play() -- If control is pressed, play CrouchStart animation again
end
end
end)
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.S and controlPressed then
-- If control is pressed and the player starts walking
CStart:Stop() -- Stop CrouchStart animation
Walk:Play()
Walk.Looped = true-- Play the walk animation
end
end)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.S then
-- If the player stops walking
Walk:Stop() -- Stop the walk animation
if controlPressed then
CStart:Play() -- If control is pressed, play CrouchStart animation again
end
end
end)
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.D and controlPressed then
-- If control is pressed and the player starts walking
CStart:Stop() -- Stop CrouchStart animation
Walk:Play()
Walk.Looped = true-- Play the walk animation
end
end)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.D then
-- If the player stops walking
Walk:Stop() -- Stop the walk animation
if controlPressed then
CStart:Play() -- If control is pressed, play CrouchStart animation again
end
end
end)
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.W then
WDown = true
end
end)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.W then
WDown = false
end
end)
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.A then
ADown = true
end
end)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.A then
ADown = false
end
end)
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.S then
SDown = true
end
end)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.S then
SDown = false
end
end)
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.D then
DDown = true
end
end)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.D then
DDown = false
end
end)
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
shiftPressed = true
if controlPressed == false and WDown or ADown or SDown or DDown then
local properties = {FieldOfView = DefaultFOV + 15}
local Info = TweenInfo.new(0.5,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0.1)
local T = game:GetService("TweenService"):Create(game.Workspace.CurrentCamera,Info,properties)
T:Play()
RunAnim:Play()
end
end
end)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
shiftPressed = false
local properties = {FieldOfView = DefaultFOV - 15}
local Info = TweenInfo.new(0.5,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0.1)
local T = game:GetService("TweenService"):Create(game.Workspace.CurrentCamera,Info,properties)
T:Play()
RunAnim:Stop()
end
end)
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.W then
RunService.Heartbeat:Connect(function()
if shiftPressed then
if controlPressed == false then
Hum.WalkSpeed = RunSpeed
if WDown or ADown or SDown or DDown then
end
end
else
Hum.WalkSpeed = WlkSpeed
RunAnim:Stop()
if controlPressed == true then
Hum.WalkSpeed = CrouchSpeed
end
end
end)
end
end)