Why is my Billboard GUI 'lagging'?

Hello all!

I’m just starting to create a new game and I’ve ran into a problem already. I’m not sure how to explain it but my billboard is ‘lagging’ or following my character’s trail instead of being at the exact position I want.

Video:

Script:

local Players = game:GetService("Players")
local Billboard = game:GetService("ServerStorage"):WaitForChild("BillboardPart")

Players.PlayerAdded:Connect(function(Player)
	
	local character = Player.Character or Player.CharacterAdded:Wait()
	
	local leaderstats = Instance.new("Folder", Player)
	local StepsValue = Instance.new("NumberValue", leaderstats)
	
	local NewBillboard = Billboard:Clone()
	NewBillboard.BillboardGui.PlayerName.Text = Player.Name.." has"
	NewBillboard.Parent = workspace
	
	
	game:GetService("RunService").Heartbeat:Connect(function()
		NewBillboard.BillboardGui.steps.Text = StepsValue.Value
		NewBillboard.Position = character.Head.Position + Vector3.new(0,2,0)
	end)
end)

Billboard setup:
Screen Shot 2022-07-15 at 9.15.31 PM

Any help is appreciated! Thanks
Tomroblox54321

You’re repositioning it every heartbeat. Instead, do this:

local Players = game:GetService("Players")
local Billboard = game:GetService("ServerStorage"):WaitForChild("BillboardPart")

Players.PlayerAdded:Connect(function(Player)
	
	local character = Player.Character or Player.CharacterAdded:Wait()
	
	local leaderstats = Instance.new("Folder", Player)
	local StepsValue = Instance.new("NumberValue", leaderstats)
	
	local NewBillboard = Billboard:WaitForChild("BillboardGui"):Clone()
	NewBillboard.BillboardGui.PlayerName.Text = Player.Name.." has"
	NewBillboard.Parent = workspace
	NewBillboard.StudsOffset = Vector3.new(0, 2, 0)
	
	
	game:GetService("RunService").Heartbeat:Connect(function()
		NewBillboard.BillboardGui.steps.Text = StepsValue.Value
	end)
end)
1 Like

Put this as a server script

script.LocalScript:Clone().Parent = game.StarterPlayer.StarterCharacterScripts

local Players = game:GetService("Players")
local Billboard = game:GetService("ServerStorage"):WaitForChild("BillboardPart")

Players.PlayerAdded:Connect(function(Player)

	local character = Player.Character or Player.CharacterAdded:Wait()

	local leaderstats = Instance.new("Folder", Player)
	local StepsValue = Instance.new("NumberValue", leaderstats)

	local NewBillboard = Billboard:Clone()
	NewBillboard.BillboardGui.PlayerName.Text = Player.Name.." has"
	NewBillboard.Parent = workspace
	
	NewBillboard.Name = Player.Name .. "'s Billboard"

	game:GetService("RunService").Stepped:Connect(function()
		NewBillboard.BillboardGui.steps.Text = StepsValue.Value
Billboard.Position = game.Players.LocalPlayer.Character.Head.Position + Vector3.new(0,2,0) -- I added this so other players will see your billboard.
	end)
end)

Put this as a LocalScript parented into the server script

Billboard = game.Workspace:WaitForChild(game.Players.LocalPlayer.Name .. "'s Billboard")

game:GetService("RunService").RenderStepped:Connect(function()
	Billboard.Position = game.Players.LocalPlayer.Character.Head.Position + Vector3.new(0,2,0)
end)

I tested this for a little bit and it does not have any delay.

Edit - I added the same thing for the server so other players will see your billboard, but for other players it will be laggy like the original. Some solutions for the server would be welding it to the player’s head, and trying a while true do wait(). I think the best solution would be welding it to the player’s head and moving the position of it up a little bit.

1 Like

Thanks it worked!
@daisytheghostchild98 thanks for trying to help.

NewBillboard.Position = character.Head.Position + Vector3.new(0,2,0)

This isn’t really necessary, you could just constrain the billboard to the player’s character via a ‘JointInstance’, i.e; a ‘Weld’.

Instead of doing this, you should just set the adornee of the billboardgui to the player’s head.

https://developer.roblox.com/en-us/api-reference/property/BillboardGui/Adornee

This will prevent the unnecessary renderstepped connection. And move up the billboard using ‘StudsOffsetWorldSpace’ or ‘StudsOffset’

Edit:

To change the billboardgui to the steps, use .Changed!
https://developer.roblox.com/en-us/api-reference/event/Instance/Changed

^ This event fires whenever the value of the steps has changed.

I have taken away the solution from @temporaryacount101 because in testing it is doesn’t work due to being client sided.

I edited my original post so you can try the new code and if it’s still not what you want then you could try the other suggestions I put at the bottom where it says "Edit - "

I figured out a new way but since it works I’ll re-credit you for the solution.