Animation not playing using the Tool.Activated Event?

Hello DevForum! I’m currently having an issue using the Tool.Activated event, this is being run by a server script under the tool in question, here’s the script:


--Variables
local WGF = script.Parent
local Anim = script.Parent:WaitForChild("Animation")

--Sounds
local NormalDorya = script.Parent:WaitForChild("Kazuya Dorya")
local EWGFDorya = script.Parent:WaitForChild("Kazuya Dorya EWGF")


WGF.Activated:Connect(function()
	local Character = WGF.Parent
	local Humanoid = Character:FindFirstChild("Humanoid")
	local Animator = Humanoid:FindFirstChild("Animator")
	local LoadedAnimation = Animator:LoadAnimation(Anim)
	NormalDorya.Parent = Character:WaitForChild("HumanoidRootPart")
	LoadedAnimation:Play()
	NormalDorya:Play()	
	print("EWGF ACTIVATED")
end)

Does anyone know why the animation isn’t playing when i activate the tool? Am I missing something? Thank you!

4 Likes

Are you sure that you can check in a ServerScript if a tool has been activated ? Shouldn’t this script go in a LocalScript instead ?

4 Likes

I’ve already tried a LocalScript, the same issue persists, and it’s possible to find the player from a Serverscript.

2 Likes

Where did you put the localscript ? It shouldn’t go in the tool, it should actually go in StarterPlayer, and then StarterCharacterScripts or StarterPlayerScripts. From the server, you can indeed get a player, but you can’t check if he activated a tool I think.

Regarding your code, I also see NormalDorya:Play() ? If it’s an animation, you should load it like you did with anim.

3 Likes

Have you placed that LocalScript inside the tool? Also, does everyone need to see the animation, or is it just meant for the LocalPlayer?

2 Likes

yes i’ve placed the localscript inside the tool, everyone needs to see the animation, and I know its supposed to be working because I’ve played an animation from a localscript under a tool before.

2 Likes

NormalDorya is a sound. Also I’m not sure if i want to place all of my animations inside StarterCharacterScripts, mainly for organization purposes, and I’ve run an animation from a localscript under a tool before.

2 Likes

Okay, so then you should use RemoteEvents each time you equip the tool (through a local script), you send an event to the server. When the server (a ServerScript) receives the event, you should then animate the player (and possibly play the sound).
This will ensure that every other player sees the animation and hears the sound too.

2 Likes

i want it to play only when the tool has been activated. Also thats just a bunch of unnecessary steps to play a single animation, plus I’ve done it before in one singular localscript under a tool.

2 Likes

Could you debug it and look where it breaks? Also i whould recomend a check if the animation is loaded. Try it and debug it to see if there are errors. Heres an example:

--Variables
local WGF = script.Parent
local Anim = script.Parent:WaitForChild("Animation")

--Sounds
local NormalDorya = script.Parent:WaitForChild("Kazuya Dorya")
local EWGFDorya = script.Parent:WaitForChild("Kazuya Dorya EWGF")


WGF.Activated:Connect(function()
	local Character = WGF.Parent
	local Humanoid = Character:FindFirstChild("Humanoid")
	local Animator = Humanoid:FindFirstChild("Animator")
	local LoadedAnimation = Animator:LoadAnimation(Anim)
	NormalDorya.Parent = Character:WaitForChild("HumanoidRootPart")
	
	if LoadedAnimation then
		LoadedAnimation:Play()
	else
		print("Failed to load animation.")
	end

	NormalDorya:Play()	
	print("EWGF ACTIVATED")
end)
1 Like

tried this, gave me nothing in the output

1 Like

Could you put a print above the character to see if it even detects when it activates? Btw, please remember that Animations won´t work in Studio.

1 Like

Alright, turns out it doesn’t even detect when it activates, not sure what the issue is though.

1 Like

Just to clarify, you placed that script inside the tool itself, not within any part of the tool, correct?

2 Likes

I fixed it, i made a mistake, i didnt know that i had to have the requireshandle property off when you dont have a handle, that sounds dumb but atleast i got it fixed! Thank you for your help too btw.

2 Likes

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