Need help with overhead gui displaying a leaderboard stat value

you already have the bottom half its your character Added function the top half isn’t finish its just example code for showing health.Did you make a script for the billboardGui to update its value based on the time value?

“Did you make a script for the billboardGui to update its value based on the time value?” wdym by that

Why does your billboard gui variable say it is in server script service?

Also, there is no local script in it which you are disabling.

1 Like

true my bad typos was about to go getting tired

Its my first reply…

I don’t think you’re trying to meet me halfway just copy and pasting my example code

local Players = game:GetService('Players')
local BillboardGui = game.ServerStorage.BillBoardGui

Players.PlayerAdded:Connect(function(Player)
	
	Player.CharacterAdded:Connect(function(Character)
		local BillboardClone = BillboardGui:Clone()
			BillboardClone.Parent = Character:WaitForChild("Head")			
			BillboardClone.LocalScript.Disabled = false
	end)
		
end)

There was an error

you need to do whats below… I’m going to stop typing out code now

1 Like

Please show all your scripts and the billboard gui and their parents

This is one
image

The Script is:

local humanoid = character.Humanoid

local player = game.Players:GetPlayerFromCharacter(character)

local leaderstats = player.leaderstats
local timeAlive = leaderstats["Time Alive"]
local bestTime = leaderstats["Best Time"]

local regionPart = workspace.Region

local min = regionPart.Position - (0.5 * regionPart.Size)
local max = regionPart.Position + (0.5 * regionPart.Size)
local region = Region3.new(min, max)

local function CheckSpawnRegion()
	local objects = workspace:FindPartsInRegion3WithWhiteList(region, {character})
	
	if #objects > 0 then
		if not character:FindFirstChildOfClass("ForceField") then
			local forceField = Instance.new("ForceField")
			forceField.Visible = true
			forceField.Parent = character
		end
		
		return true
	else
		local forceField = character:FindFirstChildOfClass("ForceField")
		
		if forceField then
			forceField:Destroy()
		end
		
		return false
	end
end

local hasDied = false

humanoid.Died:Connect(function()
	hasDied = true
end)

while wait() do
	if hasDied then break end
	
	while not hasDied and not CheckSpawnRegion() do
		timeAlive.Value += 1
		
		if timeAlive.Value > bestTime.Value then
			bestTime.Value = timeAlive.Value
		end
		
		wait(1)
	end
	
	if hasDied then
		timeAlive.Value = 0
	end
end```

This is another one
This script is from ServerScriptService

local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("DataStore")

local function CreateStat(name, class, value, parent)
	local stat = Instance.new(class)
	stat.Name = name
	stat.Value = value
	stat.Parent = parent
	
	return stat
end

local function GetKey(player)
	return player.UserId .. "-"
end

local function SaveData(player)
	local key = GetKey(player)
	
	local leaderstats = player.leaderstats
	local timeAliveData = leaderstats["Time Alive"].Value
	local bestTimeData = leaderstats["Best Time"].Value
	
	local success, result = pcall(function()
		DataStore:SetAsync(key .. "TimeAlive", timeAliveData)
		DataStore:SetAsync(key .. "BestTime", bestTimeData)
	end)
	
	if not success then
		warn(result)
	end
end

game.Players.PlayerAdded:Connect(function(player)
	local key = GetKey(player)
	
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	local timeAlive = CreateStat("Time Alive", "IntValue", 0, leaderstats)
	local bestTime = CreateStat("Best Time", "IntValue", 0, leaderstats)
	
	local timeAliveData, bestTimeData
	
	local success, result = pcall(function()
		timeAliveData = DataStore:GetAsync(key .. "TimeAlive")
		bestTimeData = DataStore:GetAsync(key .. "BestTime")
	end)
	
	if success then
		timeAlive.Value = timeAliveData or 0
		bestTime.Value = bestTimeData or 0
	else
		warn(result)
		player:Kick("Error occured while retrieving your saved data.")
	end
end)

game.Players.PlayerRemoving:Connect(SaveData)

if not RunService:IsStudio() then
	game:BindToClose(function()
		if #game.Players:GetPlayers() <= 1 then return end
		
		for _, player in pairs(game.Players:GetPlayers()) do
			SaveData(player)
		end
	end)
end```
1 Like

image

i told u before those scripts have nothing to do with the billboard ui ur confusing them
to be speicfic the time and the datastore

Whats the full script for the nametags?

It’s time overhead

like this image

I said the current script for the nametags you have at the moment.

This is in ServerScriptService

local BillboardGui = game.ServerStorage.BillBoardGui

Players.PlayerAdded:Connect(function(Player)

	Player.CharacterAdded:Connect(function(Character)
		local BillboardClone = BillboardGui:Clone()
		BillboardClone.Parent = Character:WaitForChild("Head")			
		BillboardClone.LocalScript.Disabled = false
	end)

end)

Can you show the script that updates it according to the leaderstats?

TimeScript in StarterCharcterScripts

local humanoid = character.Humanoid

local player = game.Players:GetPlayerFromCharacter(character)

local leaderstats = player.leaderstats
local timeAlive = leaderstats["Time Alive"]
local bestTime = leaderstats["Best Time"]

local regionPart = workspace.Region

local min = regionPart.Position - (0.5 * regionPart.Size)
local max = regionPart.Position + (0.5 * regionPart.Size)
local region = Region3.new(min, max)

local function CheckSpawnRegion()
	local objects = workspace:FindPartsInRegion3WithWhiteList(region, {character})
	
	if #objects > 0 then
		if not character:FindFirstChildOfClass("ForceField") then
			local forceField = Instance.new("ForceField")
			forceField.Visible = true
			forceField.Parent = character
		end
		
		return true
	else
		local forceField = character:FindFirstChildOfClass("ForceField")
		
		if forceField then
			forceField:Destroy()
		end
		
		return false
	end
end

local hasDied = false

humanoid.Died:Connect(function()
	hasDied = true
end)

while wait() do
	if hasDied then break end
	
	while not hasDied and not CheckSpawnRegion() do
		timeAlive.Value += 1
		
		if timeAlive.Value > bestTime.Value then
			bestTime.Value = timeAlive.Value
		end
		
		wait(1)
	end
	
	if hasDied then
		timeAlive.Value = 0
	end
end

And does the billboard gui even have a local script in it? (As it’s child)

I meant the script that updates the text label

He hasn’t made one i believe he just wants someone to do the work for em. he doesn’t seem to have much experience