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

What's wrong with this script?

Asked by 9 years ago
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.

0
Please place the code in a code block. Thank you. M39a9am3R 3210 — 9y

1 answer

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

Answer this question