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 4 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?

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

Log in to vote
3
Answered by 4 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 — 4y
0
Np :) ffancyaxax12 181 — 4y
1
Upvoted ;D Xapelize 2658 — 4y
0
Ty :> ffancyaxax12 181 — 4y
Ad

Answer this question