Changes to the health property of a Humanoid instance will not replicate to the server if done from the client, you’ll need to use a RemoteEvent to fire the server and then in some server script perform the health deduction.
this is not correct. the humanoid is inside the player character.
add ‘.LocalPlayer’ to that.
If you really wanna do it from the client, destroy the player’s head. That replicates to the server. if you want to kill the player via a local script do this:
local player = game:GetService('Players').LocalPlayer
local character = player.Character
local head = character:FindFirstChild('Head')
head:Destroy() --death by beheading, funny
Or do what Forummer said, which is a lot more practical.
Okay so basically you need to understand client vs server
Client: The individual player (local script)
Server: All players (script)
Game.Players.LocalPlayer
refers to the individual player. Since the server is all players and not individual players it doesnt know what the individual player is. You can tell it what player to affect by saying
Game.Players.(playername)
If you do want to use Game.Players.LocalPlayer you would have to do it on the client. (remember the client is a local script) This is because, since the client is every individual player, it knows what you are talking about. The game clones the local script to every player that joins, so every player that joins has a different local script with data thats important to them specifically. (like their player properties)
The reason I see in my code why I wasn’t able to change the players health was because I was trying to say Player.Health which health is not a property of player. Instead what I should have done is say
Player.Character.Humanoid.Health
Saying game.Players.LocalPlayer gets the player model inside of the players tab
But saying game.Players.LocalPlayer.Character gives me the players character which is located inside of workspace
The humanoid is a child of the players character inside of workspace so you have to reference Player.Character then you say
Player.Character.Humanoid.
Health is indeed a property of every humanoid
@Ma7adi805 Tell me if this helps. Sorry for being rude earlier, I thought you were someone who was responding to my post in terms of trying to help me, not get help.
Looks Like The image is not uploading so I will be saying it by text
20:29:30 -- Humanoid is not a valid member of Model "Workspace.Ma7adi805"
Stack Being
Script 'Players.Ma7adi805.PlayerGui.Settings.Settings2.confirmication.Yes.LocalScript', Line 6