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?
How can I make a leaderstat billboard gui above everyone's head, showing off their amounts of time?
3 answers
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.
2 comments
Hey! This worked! I asked another simple question in the chat, could you check that out?
I cannot make it centered since it relies on the length of the text of the label.
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)
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)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
I keep trying, but every single thing I can possible think of, doesn't work. Can anyone help?