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

How can I make a leaderstat billboard gui above everyone's head, showing off their amounts of time?

Asked by 4 years ago

I'm trying to make a working billboard GUI above everyone's head, so that everyone can see each other's times (the leaderstat). How could I do that?

0
I keep trying, but every single thing I can possible think of, doesn't work. Can anyone help? KreativleV2 0 — 4y

3 answers

Log in to vote
1
Answered by
Ghost40Z 118
4 years ago

First of all, you need to make the value. Make a ServerScript in the ServerScriptService.

game.Players.PlayerAdded:Connect(function(player)
    local Time = Instance.new("IntValue", player)
    Time.Name = "Time" --Value name
    Time.Value = 0 --Starting time

    player.CharacterAdded:Connect(function()
        local ReplicatedStorage = game.ReplicatedStorage --The GUI Location
        local BillboardGui = ReplicatedStorage.BillboardGui --The GUI itself
        local head = player.Character.Head --the player's head

        local Clone = BillboardGui:Clone() --Clones the gui from Replicated storage
        Clone.Parent = head --Sets the billboard Gui into the players head
    end)
end)

You need to make a LocalScript in StarterPlayer.StarterCharacterScripts and also add a remote event in the ReplicatedStorage.

local player = game.Players.LocalPlayer --player
while wait(1) do --runs loop 1 time every second
    game.ReplicatedStorage.RemoteEvent:FireServer(player) --fires remote event
end

Inside the pre-made billboard GUI, you need a ServerScript (The script needs to be put inside the TextLabel)

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player)
    local Time = player.Time
    Time.Value = Time.Value + 1

    script.Parent.Text = "Time Played: "..Time.Value.." seconds."
end)

If you follow the instructions correctly it should work. I tested it and sure enough, It worked. Have a nice day.

0
Hey! This worked! I asked another simple question in the chat, could you check that out? KreativleV2 0 — 4y
0
I cannot make it centered since it relies on the length of the text of the label. Ghost40Z 118 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

The answer is must simplier, just place the time billboard gui in a place like serverStorage, and put a script in ServerScriptService, and type this

local players = game:GetService("Players")
local serverStorage = game:GetService("ServerStorage")
local billboard = serverStorage.YourBillboardGui

players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        local head = character:FindFirstChild("Head")
        if (head and not head:FindFirstChild(billboard.Name)) then
            local billboardClone = billboard:Clone()
            local time = 0 -- put the text here
            coroutine.wrap(function()
                while true do
                    wait(1)
                    time += 1
                end
            end)()
            billboardClone.TextLabel.Text = tostring(time)
            billboardClone.Enabled = true
            billboardClone.Parent = head
        end
    end)
end)
Log in to vote
0
Answered by 4 years ago

First thing first create a billboard Gui on a part to adjust it to the size you want it to be, after it put it in "ReplicatedStorage" and create a leaderstats that represents the time that the player been on the server. After your done with it just add a PlayerAdded function and clone and do player.leaderstats.TimePlayed.Changed:Connect(function()

script.Parent.Text = player.leaderstats.TimePlayed.Value

end)

Answer this question