Local or Server script?

Just a quick question about scripts. I’ve run into a small snag while building a BillboardGui. I want it to display how much resource is left till a rebirth and I keep running into errors. The BillboardGui is attached to a part in a model in Workspace (and then a bunch of folders). I’ve tried using a normal script, get the player, then try to display the information from a a value. Since I want everyone to see their own values I then thought after a few errors attempts that it should be a local script but what do I do with the part its attached to. What am I missing?

What code are you using to accomplish this?

If the billboard is attached to a part, it will stay this way, server or client. If you are simply editing a value of a TextLabel (or similar) inside the BillboardGui from the Client, then only that Client that the value has been edited from will be able to see it.

Although you might know this, its still good to know:


A Script is set of Instructions for the computer to read and execute.
A Script in Roblox is the Exact thing but runs on the Server for Everyone to see.


A LocalScript is a script used for the Player, Changes on this script can only be seen by the player

I am not getting very far since this already has error.

local player = game:GetService("Players")

local function getCoinInfo(player)

	local coins = player.LocalPlayer:WaitForChild("leaderstats").Coins


attempt to index nil with ‘leaderstats’

This shouldn’t be a local script. Make it a server script.

You will need to make your system compatible.

You need to make it a local script but it shouldn’t be a local script. You should be able to do this on the server as well but you can’t use local player.

So I made it a local script and it works but I need it to now update when coins.Value changes. How should I implement that?

local billboard = workspace.GameAssets.WorldAssets.Zone1Assets.ScriptedModels.RebirthHouse["RebirthPart(Scripted)"].BillboardGui

local function getCoinInfo()
	local player = game.Players
	local char = player.LocalPlayer
	local leaderstats = char:FindFirstChild("leaderstats")
	local coins = leaderstats:FindFirstChild("Coins")
	local rebirth = leaderstats:FindFirstChild("Rebirth")
	local rebirthBaseCost = game.ReplicatedStorage.RebirthValue.Value
	local newRebirthCost = rebirthBaseCost * ((rebirth.Value * 2.5) * 1.05)

	if coins.Value >= newRebirthCost then
		billboard.Frame.TextLabel.Text = "Ready to rebirth!"
		local neededCoins = newRebirthCost - coins.Value
		billboard.Frame.TextLabel.Text = tostring(neededCoins .." coins needed to rebirth!")


Try this:

local Players = game.Players


local L = p:WaitForChild("leaderstats")
local C = L.Coins


Yeah but the PlayerAdded function runs only once. If I could’ve gotten it to display the coins.Value I would’ve then just ran a changed event to update it as the coins updated rather than just once when a player logs in. I’ve since changed (as advised) to local script in StarterGui (shown in comments above) and now I need to find a way for it to update when coins changed.

You would want a LocalScript for this. Try parenting the BillboardGui to the PlayerGui, then adorning it to the part using its adornee property. It will then appear attached to the part but LocalScripts will still run as it’s a descendant of the PlayerGui, and since it’s a LocalScript, you can then access the LocalPlayer.