Having problems with billboardGui scripting

Hi, i’m currently making a gamepass for the game i’m working on, i’ve been stuck on this for some time. So the goal is to basically add a purchasable title which is controlled by the player, with a remote with many buttons, each changing the color of it, and i am wondering why mine isn’t working, and if there is a better way to do it!

Details

  • the billboard is in the players head.
  • there is a script that has a gamepass, which clones the gui into the players head

Script

The script is in a normal script, located in ServerScriptService:

 local OverheadRemote = game.StarterGui.OverheadTitleSettings.OverheadRemote

OverheadRemote.BlackColorChanger.Activated:Connect(function(activated)
	game.Players.LocalPlayer.Character.Head.TitleGui.TitleLabel.TextColor3 = Color3.new(99,99,99)
end)

feel free to ask if there are any important details/information missing i didn’t add.

thanks!

First off there is a problem with this line:

local OverheadRemote = game.StarterGui.OverheadTitleSettings.OverheadRemote

You should place all your Remotes in ReplicatedStorage so that both the server and the client can access them. ReplicatedStorage is designed for this exact purpose.


The next issue comes with the function line:

OverheadRemote.BlackColorChanger.Activated:Connect(function(activated)

This isn’t how you listen for the Remote call. Assuming you are using a RemoteEvent and this script is on the server then you should be using the OnServerEvent event to listen for when the remote has been fired.


Then the last issue comes with this line:

game.Players.LocalPlayer.Character.Head.TitleGui.TitleLabel.TextColor3 = Color3.new(99,99,99)

You can only use game.Players.LocalPlayer on the client in a LocalScript. To be able to access the player from the server in your scenario the OnServerEvent’s first parameter is the player object. Here is how you would use it: player.Character.


The code below is your code fixed and it is assuming you have your remotes placed within ReplicatedStorage and this is a script being ran on the server:

local OverheadRemote = game.ReplicatedStorage.OverheadTitleSettings.OverheadRemote

OverheadRemote.BlackColorChanger.OnServerEvent:Connect(function(player,activated) -- The first parameter is always the player object
	player.Character.Head.TitleGui.TitleLabel.TextColor3 = Color3.new(99,99,99) -- This line uses the the player object returned by the OnServerEvent
end)

Here is a few Developer Hub articles that may be of use to you:

3 Likes
  1. Use the offset property to adjust the players title. (More likely the Y axis as it’s stuck in the players head)

Also, what do you mean by this:

1 Like

now that i read it again, it does sound a little confusing, so what i mean is that is the purpose of this script, (to clone the title into the player, when the gamepass purchase is finished) kinda to explain the purpose so that the code/script makes more sense kinda.