Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do i make this script works?

i made this script:

local nameplayer = game.Players.LocalPlayer
local playername = nameplayer:GetFullName()

local name = print(playername)

game.Players.nameplayer:GetFullName().PlayerGui.Boas_Vindas.Frame.Visible = false
while false do
	script.Parent.Parent.Parent.Workspace.LocalPlayer.Humanoid.Health = 0
end

to kill the player when he closes my GUI but dont work. im stuck on line 6

i tried everthing that i know(im a begginer on scripting).

Please Help.

3 answers

Well, the while do loop is running off the false statement. Change that to kill the player when the frame is no longer visible.

Also, if you are trying to kill nameplayer, do nameplayer.Character.Humanoid.Health = 0

But I am assuming you are killing a object in workspace with a humanoid instance.

while game.Players.nameplayer:GetFullName().PlayerGui.Boas_Vindas.Frame.Visible == false do
	script.Parent.Parent.Parent.Workspace.LocalPlayer.Humanoid.Health = 0 --Note this will kill the player everytime it respawns.
end

Your paths are the problem. Use the local variables that you set.

This starts on line 6.

playername.PlayerGui.Boas_Vindas.Frame.Visible = false
if playername.PlayerGui.Boas_Vindas.Frame.Visible == false then
	nameplayer.Humanoid.Health = 0
end

I have no way of testing this, so I hope it works.

now happen this.

12:48:03.817 - Players.Player1.Backpack.LocalScript:4: attempt to index field 'playerGui' (a nil value)

This discussion is preserved as it was. New answers, comments, and votes are closed.