Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Tool script won't run function on activation?

So I am trying to make a script that swings a knife when you click. Because the knife will interact with other players on the server, I thought I'd make it a serverscript. So I wrote the script along with the variables I'll need for animating. Getting the humanoid works, but the script fails to print "yay" (which is a placeholder for Track:Play() ) Does anyone know why this is happening? What can I do to fix it?

local hum = nil
script.Parent.Equipped:Connect(function()
	hum = script.Parent.Parent:WaitForChild("Humanoid")
	print(hum)
end)

local anim = Instance.new("Animation")
anim.Name = "KnifeAnim1"
anim.AnimationId = "http://www.roblox.com/asset/?id=4657391308"
local Track = hum:LoadAnimation(anim)
local PlayingAnimations = hum:GetPlayingAnimationTracks() -- I'll use this later to stop the other tracks

script.Parent.Activated:Connect(function()
	print("yay")
end)

1 answer

Well, the animation needs to be a local script because the player is performing the animation. But you could have another script inside the Knife that fires a Remote Function to the server to tell the other player to take damage.

4 comments

0

Thanks for telling me! I wouldn't have realized that since I'm new to animating through scripts.

0

Np :)

1

Upvoted ;D

0

Ty :>

This discussion is preserved as it was. New answers, comments, and votes are closed.