Hi, total noob to RemoteEvents here. I'm making a weapon. When the handle of the weapon is touched by somebody other than the Player who is attacking, it takes damage to the victim. I have two values, attacking and debounce. The code is inside a local script inside the tool. The RemoteEvent is in ReplicatedStorage, and the script is inside ServerScriptService.
The clip of the local script containing the :FireServer() looks like this:
function onTouch(part)
if attacking == true and debounce == true then
if part.Parent.Name ~= player.Name then
local vhum = part.Parent:findFirstChild("Humanoid")
if vhum and vhum.Health > 0 then
game.ReplicatedStorage.RemoteEvents.TakeHealthFromWeapon:FireServer(player, vhum, damage)
attacking = false
end
end
end
end
The script looks like this:
function onTHFW(vhum, damage)
vhum.Health = vhum.Health - damage
end
game.ReplicatedStorage.RemoteEvents.TakeHealthFromWeapon.OnServerEvent:connect(onTHFW)
When the tool is activated, I get this error from the Script:
"21:41:29.298 - Health is not a valid member of Player" ... "21:49:55.547 - Script 'ServerScriptService.Script', Line 3"
Any help is appreciated. Thanks. :} ~Loughdough

1 comment
Health is not a valid member of Player. Use Player.Character.Humanoid.Health instead.