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
Locked by TofuBytes, Perci1, and Shawnyg
This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.
Why was this question closed?