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

How do i make this script works?

Asked by 10 years ago

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

Log in to vote
0
Answered by
ked2000 15
10 years ago

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
Ad
Log in to vote
0
Answered by 10 years ago

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.

Log in to vote
0
Answered by 10 years ago

now happen this.

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

Answer this question