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!
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.
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.
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.
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.
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.
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)
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.