Basically I’m trying to add so that whenever a player joins my game they have a billboard showing how many wins they have, however my code seems fine, but no gui is appearing. I’m horrible with gui so I can’t really figure out what the problem is anyone know what it is?
local Players = game:GetService("Players")
--Function to set up the BillboardGui for a player
local function setupBillboard(player)
local char = player.Character or player.CharacterAdded:Wait()
local head = char:WaitForChild("Head") -- Ensure the head exists
--Create the BillboardGui
local winsBillboard = Instance.new("BillboardGui")
winsBillboard.Name = "WinsBillboard"
winsBillboard.Size = UDim2.new(0, 200, 0, 50) --Adjust size as needed
winsBillboard.Adornee = head -- Attach to the player's head
winsBillboard.Parent = char --Parent it to the character
--Create the TextLabel
local textBox = Instance.new("TextLabel")
textBox.Name = "TextBox"
textBox.Size = UDim2.new(1, 0, 1, 0) -- Fill the BillboardGui
textBox.BackgroundTransparency = 1 -- Make background transparent
textBox.TextScaled = true --Scale text to fit
textBox.Text = player.leaderstats.Wins.Value .. " Wins" --Set initial text
textBox.Parent = winsBillboard --Parent the TextLabel to the BillboardGui
--Create the UICorner (optional, for rounded corners)
local curve = Instance.new("UICorner")
curve.Parent = textBox
--Update the text when the Wins value changes
player.leaderstats.Wins.Changed:Connect(function(newWins)
textBox.Text = newWins .. " Wins"
end)
end
-- Connect the setup function to PlayerAdded and events
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
-- Wait for leaderstats to be set up
player:WaitForChild("leaderstats")
player.leaderstats:WaitForChild("Wins")
--Set up the BillboardGui
setupBillboard(player)
end)
end)