Scripting Problem

Got a error on this line in the local script, script.Parent.Text = Status.Value

It says Text is not a valid member of PlayerScripts, is this because I put the LocalScript in StarterPlayerScripts?

1 Like

Yeah seems like it. You will need to define the TextLabel as a variable and use that variable to access it. Not exactly sure where its located but lets say its inside a Frame which is inside a ScreenGui, you would need to do something like this

local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")

local MainGui = PlayerGui:WaitForChild("ScreenGui")
local Frame = MainGui:WaitForChild("Frame")
local TextLabel = MainGui:WaitForChild("TextLabel") --use this to access the text
1 Like

Do I put this code in the local script or main script? Usually I reference in the Server Script.

1 Like

You typically want local scripts to handle GUI elements while the server handles the game mechanic itself. Essentially local scripts should only ever handle visual elements that have no impact on the gameplay itself.

1 Like

Put that code in the local script, is this right or is it jumbled up? I checked for any errors none came up. I also put the local script inside the Status GUI not inside the frame.

local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild(“PlayerGui”)

local MainGui = PlayerGui:WaitForChild(“ScreenGui”)
local Frame = MainGui:WaitForChild(“Frame”)
local TextLabel = MainGui:WaitForChild(“TextLabel”)

local Status = game:GetService(“ReplicatedStorage”):WaitForChild(“Status”)

script.Parent.Text = Status.Value

Status:GetPropertyChangedSignal(“Value”):Connect(function()

script.Parent.Text = Status.Value

end)

1 Like

change this

to

TextLabel.Text = Status.Value

Keep in mind you can rename the variables to whatever you like, I just used those to keep it straightforward. Also you need to correctly reference where the TextLabel actually is, I just made an assumption on its location so you’ll have to do that part on your own.

1 Like

Changed it, I got a possible infinite yield on a line saying,

'Players.Coulior.PlayerGui:WaitForChild(“ScreenGui”)

I’m so confused because this has never happened to me ever and I’ve used this method for a while.

I don’t know if you understand how assigning variables to instances work but I recommend you look it up and maybe even watch a few tutorials on how to do it.

The reason why its yielding infinitely is because you don’t have anything called “ScreenGui” inside your PlayerGui. I used the name “ScreenGui” as a place holder which you should change to the name of your StarterGui instance.

Think of variable referencing as looking into folders, and every name you add after a period . is the next instance your script will attempt to identify.

1 Like

Fixed it, I redid the script and I think I had a couple things that weren’t named properly. Example I wrote down one of your scripts and It had MainGUI and in my game it was StatusGUI. Simple things like that, I appreciate your help on this script. Even though it might be very very simple for you not me lol. Next step I’m going to have to make a map voting system, Thanks Again.

Hiya! I’d suggest instead of making a whole value shabang that’s managed by something else, simply count the amount of players yourself. It will be quick and easy and all it takes it one simple loop.


local function GetPlayerNumber()
	local players = 0
	for i, Player in pairs(game:GetService("Players"):GetChildren()) do
		players += 1	
	end
	return players
end

Status.Value = "Waiting for players to join.."
repeat task.wait() until GetPlayerNumber() >= 2
Status.Value = "Intermission"
1 Like