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

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

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!

2 comments

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

0

ew wait() as your condition

3 answers

✓ Accepted answer

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)

5 comments

0

i literally said the same thing..

0

You can't just give someone the answer without explaining it at least try explaining your answers

0

welp mk then ._.

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!

0

Okay thanks!

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

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)

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