So far I am scripting my very first sword. Problem is, the only thing that works is when you equip you hear a sound. The animation doesn't work, and the actual damage it does to the other player doesn't work. Now, I don't know if the reason the animation doesn't work is because it needs to be on the server script, frankly I can't test it because my computer is acting wonky and it is just I don't know moment. As of right now I have the very bare basics of the sword, but I don't want to precede any further until it works. Plus, it is showing no errors. When I say it "doesn't work" I mean I don't know where the error exactly is, that is why I am asking because I honestly do not know. Don't know how much more specific I can be.
Server script
local tool = script.Parent.Parent
local player = tool.Parent.Parent
local character = player.Character
local event = tool.Handle:WaitForChild("Event")
local damage = 20
event.OnServerEvent:connect(function()
script.Parent.Parent.Handle.Touched:connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if hit.Parent ~= tool.Parent.Parent and humanoid ~= nil then
humanoid:TakeDamage(damage)
end
end)
end)
Local Script
local tool = script.Parent.Parent
local player = game.Players.LocalPlayer
local character = player.Character
local event = tool.Handle:WaitForChild("Event")
tool.Equipped:connect(function(equip)
script.Parent.Sound1:Play()
equip.Button1Down:connect(function()
if character then
local humanoid = character:findFirstChild("Humanoid")
if humanoid then
local animationTrack = humanoid:LoadAnimation(tool.swordthrust)
animationTrack:Play()
event:FireServer()
end
end
end)
end)

3 comments
line 02 Server Script, you can't use LocalPlayer in a server script.
You need to estimate where the error is and only show us that part for 2 reasons: Making it easier for us to read and makes us unable to steal your scripts. Also, don't expect people to help you when you post 2 long scripts and only say "It doesn't work" for your error. That's why I deemed this non-descriptive.
Actually I think it is because I told you your teaching style was wrong, but what ever works as your excuse.