Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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)

5 comments

0

Close out your PlayerAdded event

0

I don't know what that means... I'm begginer

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

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

0

if Points.Value >= (not >) 100 (I'm not sure if it works im a complete noob at scripting oof)

1 answer

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

2 comments

0

Ok i will try

0

It didn't work

This discussion is preserved as it was. New answers, comments, and votes are closed.