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

What's wrong with this script?

GUI = game.Lighting.AdminGui
game.Players.PlayerAdded:connect(function(player)
game.Workspace:WaitForChild(player.Name)
if  (player.Name == "coolcardriver1") then 
GUI:clone().Parent = player.PlayerGui
if plr.Health == 0 then --up until here it stops working
	GUI:remove() 
GUI = backup:clone() 
GUI.Parent = game.Workspace 
GUI:makeJoints() 
end 

Basically, the script is meant to show me the admin gui, the first but works until the 'if plr.name' from there it doesn't work, what I'm trying to do is make it show up after I die/respawn. Thanks.

1 comment

0

Please place the code in a code block. Thank you.

1 answer

  1. do not do (player.Name == ""), just do player.Name == ""
  2. GUI:clone().Parent should be like
local clone = GUI:Clone()
clone.Parent = player.PlayerGui

By doing

if plr.Health == 0 then --up until here it stops working
    GUI:remove()

You make the thing in Lighting removed...

the script should be like this:

GUI = game.Lighting.AdminGui

game.Players.PlayerAdded:connect(function(player)
	game.Workspace:WaitForChild(player)
		if player.Name == "coolcardriver1" then 
			local clone == GUI:clone()
			clone.Parent = player.PlayerGui
			if plr.Health == 0 then
				clone:remove() 
				--GUI = backup:clone() --Backup is not specified, so I do not understand it
				--GUI.Parent = game.Workspace --You are changing the parent of somethign that is deleted...
				--GUI:makeJoints() -- I don't see the point of this
				end 
			end -- put more end
		end
	end)
end

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