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

How do I fix this bug with the overhead GUI because its not showing correctly?

Asked by 5 years ago

Hello Scripters!

So I want to make a overhead GUI, I already made the script. But what the problem is: Everytime I am on my own in the server, it just works like perfect. But whenever another player joins, the GUI switches the tag from me to him, or it just glitches between him and me.

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
    local gui = game:GetService("ServerStorage"):FindFirstChild("BillboardGui")  --Gets the child from the script, which would be the GUI you created
    local textlabel = gui.TextLabel
    while wait() do
    if player.leaderstats.Wins.Value <= 1  then 
    textlabel.TextColor3 = Color3.fromRGB(125, 125, 125)
    textlabel.Text = "Newbie"
    gui.Parent = character.Head
elseif player.leaderstats.Wins.Value >= 25 then
    textlabel.TextColor3 = Color3.fromRGB(85,170,0)
    textlabel.Text = "Good"
    gui.Parent = character.Head
elseif player.leaderstats.Wins.Value >= 50 then
    textlabel.TextColor3 = Color3.fromRGB(255,30,30)
    textlabel.Text = "Pro"
    gui.Parent = character.Head
elseif player.leaderstats.Wins.Value >= 100 then
    textlabel.TextColor3 = Color3.fromRGB(152, 39, 152)
    textlabel.Text = "Addicted"
    gui.Parent = character.Head
            end
        end
    end)
end)

Kind Regards!

0
You only have a single instance of 'gui' Make sure to :Clone() it so you're not sharing a single instance w/ other people ScrewDeath 153 — 5y
0
ew wait() as your condition User#19524 175 — 5y

3 answers

Log in to vote
0
Answered by
Prestory 1395 Moderation Voter
5 years ago

Whats going on here is that you forgot to add :Clone() on the end of the variable gui so it will take the gui from server storage and put it on the player then the gui will not exist in server storage anymore as it has been removed and put into the player do this instead

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
    local gui = game:GetService("ServerStorage"):FindFirstChild("BillboardGui"):Clone()  --Gets the child from the script, which would be the GUI you created
    local textlabel = gui.TextLabel
    while wait() do
    if player.leaderstats.Wins.Value <= 1  then 
    textlabel.TextColor3 = Color3.fromRGB(125, 125, 125)
    textlabel.Text = "Newbie"
    gui.Parent = character.Head
elseif player.leaderstats.Wins.Value >= 25 then
    textlabel.TextColor3 = Color3.fromRGB(85,170,0)
    textlabel.Text = "Good"
    gui.Parent = character.Head
elseif player.leaderstats.Wins.Value >= 50 then
    textlabel.TextColor3 = Color3.fromRGB(255,30,30)
    textlabel.Text = "Pro"
    gui.Parent = character.Head
elseif player.leaderstats.Wins.Value >= 100 then
    textlabel.TextColor3 = Color3.fromRGB(152, 39, 152)
    textlabel.Text = "Addicted"
    gui.Parent = character.Head
            end
        end
    end)
end)

0
i literally said the same thing.. BuzzKillGT 33 — 5y
0
You can't just give someone the answer without explaining it at least try explaining your answers Prestory 1395 — 5y
0
welp mk then ._. BuzzKillGT 33 — 5y
0
Ill take a look if I will Accept your Answer yet as I still have to test it with 2 players and no-one of my friends is online. So I'll Accept it later or I will send you a message if it had not worked! maup12345 20 — 5y
0
Okay thanks! Prestory 1395 — 5y
Ad
Log in to vote
0
Answered by
herrtt 387 Moderation Voter
5 years ago

You need to do gui:Clone(), now you just change the same gui on every player. On the local gui = do local gui = game:GetService("ServerStorage"):FindFirstChild("BillboardGui"):Clone() and it will work

Log in to vote
0
Answered by 5 years ago

I think you need :Clone(), script is below, enjoy!

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
    local gui = game:GetService("ServerStorage"):FindFirstChild("BillboardGui"):Clone()
    local textlabel = gui.TextLabel
    while wait() do
    if player.leaderstats.Wins.Value <= 1  then 
    textlabel.TextColor3 = Color3.fromRGB(125, 125, 125)
    textlabel.Text = "Newbie"
    gui.Parent = character.Head
elseif player.leaderstats.Wins.Value >= 25 then
    textlabel.TextColor3 = Color3.fromRGB(85,170,0)
    textlabel.Text = "Good"
    gui.Parent = character.Head
elseif player.leaderstats.Wins.Value >= 50 then
    textlabel.TextColor3 = Color3.fromRGB(255,30,30)
    textlabel.Text = "Pro"
    gui.Parent = character.Head
elseif player.leaderstats.Wins.Value >= 100 then
    textlabel.TextColor3 = Color3.fromRGB(152, 39, 152)
    textlabel.Text = "Addicted"
    gui.Parent = character.Head
            end
        end
    end)
end)

Answer this question