Equip and Idle Animation wont play

First off, I am not very good at scripting and I have a lot to learn. So I’m trying to get my character to show the equip animation but it wont show.

robloxapp-20231011-2215156.wmv (1.2 MB)

—Server Script

local Tool = script.Parent

local Players = game:GetService("Players")

local Player = Players.LocalPlayer

local Character = Player.Character or Player.CharacterAdded:Wait()

while not Character or not Character.Parent do
	Character = Player.Character
	wait()
end

local Value = Tool:WaitForChild("Values")

local Blocking = Value:WaitForChild("Equipped")

local Equipped = Value:WaitForChild("Blocking")

local Humanoid = Character:WaitForChild("Humanoid")

local DebrisService = game:GetService("Debris")

local AnimsFold = Tool:WaitForChild("AnimFolder")

local AnimsSlash = AnimsFold:WaitForChild("Slashes")

local anims = {

	Equip =	Humanoid:LoadAnimation(AnimsFold:WaitForChild("Equip")),

	Idle = Humanoid:LoadAnimation(AnimsFold:WaitForChild("Idle")),

	Blocking = Humanoid:LoadAnimation(AnimsFold:WaitForChild("Blocking")),

	Slash1 = Humanoid:LoadAnimation(AnimsSlash:WaitForChild("S1")),

	Smash = Humanoid:LoadAnimation(AnimsSlash:WaitForChild("Smash")),

}

local Animplay = Tool.Events:WaitForChild("AnimPlay")

local AtteckE = Tool.Events:WaitForChild("Attack")

local Debounce = false

local CanDamage = false

Tool.Equipped:Connect(function()

print("eq")

	Character = Tool.Parent
	Equipped.Value = true
	Debounce = true
	Tool.Tool6D.Part0 = Character["Right Arm"]
	Tool.Tool6D.Part1 = Tool.Handle
	
	Animplay:FireAllClients(anims.Equip:Play())
	Animplay:FireAllClients(anims.Idle:Play())
	wait(1)
	Debounce = false

end)

Firstly you can’t get LocalPlayer in a server script

Secondly this doesn’t even make any sense at all, this on the client will become nil
I suggest just doing the animations locally like this:

-- LOCAL SCRIPT
local Tool = script.Parent

local Players = game:GetService("Players")

local Player = Players:GetPlayerFromCharacter(Tool.Parent) or Tool.Parent.Parent 
--[[ detect if tool is equipped or not:
if tool is in the character then we can get player from their character using Players:GetPlayerFromCharacter
however if tool is in backpack (which is child of player) then the function above will return nil, instead we just get the backpack's parent
]]

local Character = Player.Character or Player.CharacterAdded:Wait()

while not Character or not Character.Parent do
	Character = Player.Character
	wait()
end

local Value = Tool:WaitForChild("Values")

local Blocking = Value:WaitForChild("Equipped")

local Equipped = Value:WaitForChild("Blocking")

local Humanoid = Character:WaitForChild("Humanoid")

local DebrisService = game:GetService("Debris")

local AnimsFold = Tool:WaitForChild("AnimFolder")

local AnimsSlash = AnimsFold:WaitForChild("Slashes")

local anims = {

	Equip =	Humanoid:LoadAnimation(AnimsFold:WaitForChild("Equip")),

	Idle = Humanoid:LoadAnimation(AnimsFold:WaitForChild("Idle")),

	Blocking = Humanoid:LoadAnimation(AnimsFold:WaitForChild("Blocking")),

	Slash1 = Humanoid:LoadAnimation(AnimsSlash:WaitForChild("S1")),

	Smash = Humanoid:LoadAnimation(AnimsSlash:WaitForChild("Smash")),

}



local Animplay = Tool.Events:WaitForChild("AnimPlay")

local AtteckE = Tool.Events:WaitForChild("Attack")

local Debounce = false

local CanDamage = false

Tool.Equipped:Connect(function()
if debounce then return end -- if debounce is true then prevent animation from running
print("eq")

	Character = Tool.Parent
	Equipped.Value = true
	Debounce = true
	Tool.Tool6D.Part0 = Character["Right Arm"]
	Tool.Tool6D.Part1 = Tool.Handle
	
anims.Equip:Play()
	anims.Idle:Play()
-- simply plays the animation, no FireAllClients stuff
	task.wait(1) -- wait is deprecated, task.wait does its job better
	Debounce = false

end)
1 Like


Like I said, I’m not very good at scripting. And it still doesn’t work…

Rn I’m just trying to get the equip and idle animations first

Have you made sure that all the animation objects you want to play from contains an AnimationId? If not then insert the animation ids you want to play into the animationId property of those objects (you must own the animations)

Also I think your game is hacked, there’s a bunch of random scripts attempting to use loadstring (dangerous command), there’s even a animation spoofer script which might clear your animations. It could come from a free model or a plugin, try and remove them

1 Like
  1. this actually explains alot

qe

  1. i do have animation ids

qeq

  1. i made the game not to long ago idk how it can hack so quick

  2. is there anyway to fix this?

  3. i also had an animation spoofer, and i deleted it now

1 Like

Do you have them on all of the animation objects you tried to load in (5 of those you used in the script), if you don’t then temporarily remove the lines you don’t need to load animations yet from the script, only keep the ones you’re testing

Try to disable your plugins one by one to see which one is inserting hacks then delete suspicious plugins from your inventory, and check models in your game and delete unknown scripts

1 Like

it was the plugin and the code it retyped.

if **not** debounce then return end

i should have left it as

if debounce then return end

thank you so much for your help

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.