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

How to make a gui above head that shows leaderstats value?

Asked by 4 years ago

I have this leaderstats script :

game.Players.PlayerAdded:connect(function(player)
    local leader = Instance.new("Folder",player)
    leader.Name = "leaderstats"
    local Points = Instance.new("IntValue",leader)
    Points.Name = "Points"
    Points.Value = 0
    local Title = Instance.new("StringValue",leader)
    Title.Name = "Title"
    Title.Value = "Noob Finder"

    while true do
    wait(.6)
    if Points.Value > 100 then
        Title.Value = "Good Finder"
    end
    end
end)

and i want to show the title value above players head. But I tried and it didn't work for other players and it didn't update. Please help me

Gui above head script:

game.Players.PlayerAdded:connect(onPlayerRespawned)
function onPlayerRespawned(newPlayer)
    wait(1) 
    if newPlayer then
        gui=Instance.new("BillboardGui") 
        gui.Parent=newPlayer.Character.Head 
        gui.Adornee=newPlayer.Character.Head
        gui.Size=UDim2.new(4,0,2,0)
        gui.StudsOffset=Vector3.new(0,3,0)
        texta=Instance.new("TextBox")
        texta.Size=UDim2.new(1,0,1,0)
        texta.TextSize = 35;
        texta.Font = 10;
        texta.TextStrokeTransparency = 1;
        texta.TextStrokeColor3 = Color3.new(0,0,0)
        texta.BackgroundTransparency = 1
        texta.TextColor3 = Color3.new(255,255,255)
        texta.Parent=gui 
        if newPlayer.leaderstats.Title.Value == 'Noob Finder' then
            texta.Text = "[Noob Finder]"
            texta.TextColor3 = Color3.new(255,0,0)
        end
        if newPlayer.leaderstats.Title.Value == 'Good Finder' then
            texta.Text = "[Good Finder]"
            texta.TextColor3 = Color3.new(255,255,0)
        end
    end
end


function onPlayerEntered(newPlayer)
    newPlayer.Changed:connect(function (property)
        if (property == "Character") then
            onPlayerRespawned(newPlayer)
        end
    end)
end

game.Players.PlayerAdded:connect(onPlayerEntered)
0
Close out your PlayerAdded event BennyBoiOriginal 293 — 4y
0
I don't know what that means... I'm begginer YTDudekPL 5 — 4y
0
take a look ad the character added event. The player added event is for when they join the game not when the player character spawns in User#5423 17 — 4y
0
in your first script remove the inf loop as it will not stop when the player leaves the game. Take a look at the changed event for the value object IntValue User#5423 17 — 4y
0
if Points.Value >= (not >) 100 (I'm not sure if it works im a complete noob at scripting oof) PazVan800 -5 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Basically just do this.

while true do
yourgui.Text = onPlayerRespawned.PlayerGui.(location to the title).Value
wait()
end

this keeps updating the values because it's in a while loop Also change all 'connect' to 'Connect'. 'connect' is deprecated

0
Ok i will try YTDudekPL 5 — 4y
0
It didn't work YTDudekPL 5 — 4y
Ad

Answer this question