I formatted my weapon as a localscript and I'm trying to fix it to do damage to a player. When the knife is being swung it fires off to the RemoteFunction. This script which should do damage to the player, but it always prints nothing was hit when it does hit a player. Does anyone know what's wrong?
function game.ReplicatedStorage.Knife_Damage.OnServerInvoke(player)
local knife = player.Character:WaitForChild("Knife")
if knife.PlayDownStab == true then
knife:WaitForChild('Handle').Touched:connect(function(hit)
hit.Parent:findFirstChild('Humanoid').Health = hit.Parent:findFirstChild('Humanoid').Health - 50
end)
elseif knife.PlayStabPunch == true then
knife:WaitForChild('Handle').Touched:connect(function(hit)
hit.Parent:findFirstChild('Humanoid').Health = hit.Parent:findFirstChild('Humanoid').Health - 25
end)
elseif knife.PlayThrow == true then
Workspace:WaitForChild('Handle').Touched:connect(function(hit)
hit.Parent:findFirstChild('Humanoid').Health = hit.Parent:findFirstChild('Humanoid').Health - 100
end)
else
print('No Player was hit')
end
end

2 comments
Try modifying this to use a RemoteEvent instead. It doesn't look you're returning anything, or that you specifically want the function that Invokes the server to wait until this function runs completely. Also, include the code that Invokes the server.
Yes, it's now working. Thank you!