"Health Is Not A Valid Member of Player"?
Asked by
7 years ago Edited 7 years ago
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:
02 | if attacking = = true and debounce = = true then |
03 | if part.Parent.Name ~ = player.Name then |
04 | local vhum = part.Parent:findFirstChild( "Humanoid" ) |
05 | if vhum and vhum.Health > 0 then |
06 | game.ReplicatedStorage.RemoteEvents.TakeHealthFromWeapon:FireServer(player, vhum, damage) |
The script looks like this:
1 | function onTHFW(vhum, damage) |
2 | vhum.Health = vhum.Health - damage |
5 | 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