Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Text button GUI should kill player when clicked but doesn't, how do i fix this?

Asked by
Jov 0
5 years ago

this is my first time working with filtering enabled, ive made a few small games in the past but nothing good

i made a text button gui that when clicked should kill the player. This is what im having trouble with. (feel free to call me a noob) but i cant seem to figure out how to make it function as it should, here's the script.

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function()
local LocalPlayer = game.Players.LocalPlayer
LocalPlayer.Health = 0
end)

i know its sad i cant get the simplest function to work but eh i guess we all start somewhere

thanks for the help in advance!

0
Wait. If your a noob then how do you know how to use events lol? kittonlover101 201 — 5y
0
if you are trying to effect a "humanoid" you must mention it in your code. Daddonnie96 -2 — 5y

1 answer

Log in to vote
1
Answered by
Delude_d 112
5 years ago

Server scripts can't access localplayer. It needs a p (additional argument in fe) in the argument/player in the argument. For more info, view the robloxwiki or youtube videos. You're welcome. And, btw you missed to define the character then the humanoid. Humanoid holds all the properties of the character.

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(p) ---[[ in the argument, defines plr]]
local char = p.Character -- gets character
local hum = char:WaitForChild("Humanoid") -- gets humanoid

hum.Health = 0 -- This will make the hum's health zero
end)
0
thank you! Jov 0 — 5y
0
No problem! Delude_d 112 — 5y
Ad

Answer this question