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