What’s up, haven’t posted in a while. Just chilling deving. Came across this issue when i made a custom tool where it spawns and works just the custom animations don’t play nomatter what, to the client at least? But it works on the server. I checked and made sure it wasn’t anchored all the parts and names of the parts were good to go, yet nothing.
Equipping animation
Idle Animation
The code, Seems to work?
Animation Script
local tool = script.Parent
local re = tool:WaitForChild("TrapAnim")
local EQUIP_ANIM_ID = "rbxassetid://126736170107274"
local IDLE_ANIM_ID = "rbxassetid://136726544043991"
local FORCE_PRIORITY = Enum.AnimationPriority.Action4
local STOP_CONFLICTS = true
local humEquip, humIdle
local playVersion = 0
local idleStarted = false
local function getHumAnimator(char)
local hum = char and char:FindFirstChildOfClass("Humanoid")
return hum, (hum and hum:FindFirstChildOfClass("Animator")) or nil
end
local function stopAll(animator)
if not animator then return end
for _, tr in ipairs(animator:GetPlayingAnimationTracks()) do tr:Stop(0) end
end
local function startIdleIfStillEquipped(myVersion, char)
if playVersion ~= myVersion or idleStarted or not char or tool.Parent ~= char then return end
local hum, humAnimator = getHumAnimator(char)
if hum and humAnimator and IDLE_ANIM_ID ~= "" then
if STOP_CONFLICTS then stopAll(humAnimator) end
local a = Instance.new("Animation"); a.AnimationId = IDLE_ANIM_ID
humIdle = hum:LoadAnimation(a)
humIdle.Priority = FORCE_PRIORITY
humIdle.Looped = true
humIdle:Play(0, 1, 1)
end
re:FireServer("playIdle", IDLE_ANIM_ID)
idleStarted = true
end
tool.Equipped:Connect(function()
playVersion += 1; idleStarted = false
local myVersion = playVersion
local ss = game:GetService("SoundService")
local s = ss:FindFirstChild("Equip1")
if s and s:IsA("Sound") then s:Play() end
local char = tool.Parent
if not char then return end
local hum, humAnimator = getHumAnimator(char)
if hum and humAnimator and EQUIP_ANIM_ID ~= "" then
if STOP_CONFLICTS then stopAll(humAnimator) end
local a = Instance.new("Animation"); a.AnimationId = EQUIP_ANIM_ID
humEquip = hum:LoadAnimation(a)
humEquip.Priority = FORCE_PRIORITY
humEquip.Looped = false
humEquip:Play(0, 1, 1)
humEquip.Stopped:Connect(function()
startIdleIfStillEquipped(myVersion, char)
end)
end
re:FireServer("playEquip", EQUIP_ANIM_ID)
if not humEquip then
startIdleIfStillEquipped(myVersion, char)
end
end)
tool.Unequipped:Connect(function()
playVersion += 1; idleStarted = false
if humEquip then humEquip:Stop(0); humEquip = nil end
if humIdle then humIdle:Stop(0); humIdle = nil end
re:FireServer("stopAll")
end)
This is the layout of said tool,
This is the script so it attaches the tool to the player properly.
local tool = script.Parent
tool.RequiresHandle = false
local DEFAULT_C0 = CFrame.new(0,0,0)
local function getTorso(char)
return char and (char:FindFirstChild("Torso") or char:FindFirstChild("UpperTorso"))
end
local function ensureToolGrip(torso)
local grip = torso:FindFirstChild("ToolGrip")
if not grip then
grip = Instance.new("Motor6D")
grip.Name, grip.Part0, grip.C0, grip.C1, grip.Parent =
"ToolGrip", torso, CFrame.new(), CFrame.new(), torso
end
return grip
end
local function findRigAndAttach()
local attach = tool:FindFirstChild("BTBodyattach", true)
if not attach then attach = tool:WaitForChild("BTBodyattach", 2) end
if not attach then return nil, nil end
return attach:FindFirstAncestorOfClass("Model"), attach
end
local function freeParts(model)
for _, o in ipairs(model:GetDescendants()) do
if o:IsA("BasePart") then
o.Anchored = false
o.CanCollide = false
o.Massless = true
end
end
end
local function setServerOwnership(model)
for _, o in ipairs(model:GetDescendants()) do
if o:IsA("BasePart") then
pcall(function() o:SetNetworkOwner(nil) end)
end
end
end
tool.Equipped:Connect(function()
local char = tool.Parent; if not char then return end
local torso = getTorso(char); if not torso then return end
local rig, attach = findRigAndAttach()
if not rig or not attach then return end
freeParts(rig)
setServerOwnership(rig)
attach.Anchored = false
local grip = ensureToolGrip(torso)
grip.C0, grip.C1 = DEFAULT_C0, CFrame.new()
grip.Part1 = attach
end)
tool.Unequipped:Connect(function()
local char = tool.Parent; if not char then return end
local torso = getTorso(char); if not torso then return end
local grip = torso:FindFirstChild("ToolGrip")
if grip then grip.Part1 = nil end
end)
As always i appreciate any help given, thank you for your time.