Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Tool script won't run function on activation?

Asked by 5 years ago

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?

01local hum = nil
02script.Parent.Equipped:Connect(function()
03    hum = script.Parent.Parent:WaitForChild("Humanoid")
04    print(hum)
05end)
06 
07local anim = Instance.new("Animation")
08anim.Name = "KnifeAnim1"
10local Track = hum:LoadAnimation(anim)
11local PlayingAnimations = hum:GetPlayingAnimationTracks() -- I'll use this later to stop the other tracks
12 
13script.Parent.Activated:Connect(function()
14    print("yay")
15end)

1 answer

Log in to vote
3
Answered by 5 years ago

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.

0
Thanks for telling me! I wouldn't have realized that since I'm new to animating through scripts. ZeroNoey 19 — 5y
0
Np :) ffancyaxax12 181 — 5y
1
Upvoted ;D Xapelize 2658 — 5y
0
Ty :> ffancyaxax12 181 — 5y
Ad

Answer this question