Trying to make a status gui but it resets every time a new player joins the game

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to make a status gui that changes it’s text after an amount of time i selected.
  2. What is the issue? Include screenshots / videos if possible!
    The text changes to all the players but the problem is that it resets every time a new player joins
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have read some devforum posts and changed my code a little but nothing worked.

So like I said I am trying to make a facility status gui for a prison game but the text resets and the script runs from the start each time a new player joins. I want it not to reset. So this is a local script inside the text label:

ReplicatedStorage = game:GetService("ReplicatedStorage")
Cell = ReplicatedStorage.StatusEvents.CellBlock
Gym = ReplicatedStorage.StatusEvents.GymTime
Shower = ReplicatedStorage.StatusEvents.ShowerTime
Lunch = ReplicatedStorage.StatusEvents.LunchTime
Recreational = ReplicatedStorage.StatusEvents.Recreational
Free = ReplicatedStorage.StatusEvents.FreeTime
local CellText = "Cell Block Time"
local GymText = "Gym Time"
local ShowerText = "Shower Time"
local LunchText = "Lunch Time"
local RecreationalText = "Recreational"
local FreeText = "Free Time"

while true do
		Cell:FireServer(CellText)	
		wait(10)
		Gym:FireServer(GymText)
		wait(240)
		Shower:FireServer(ShowerText)
		wait(240)
		Lunch:FireServer(LunchText)
		wait(120)
		Recreational:FireServer(RecreationalText)
		wait(240)
		Free:FireServer(FreeText)
		wait(360)
	end

and this is a normal script inside the text label:

ReplicatedStorage = game:GetService("ReplicatedStorage")
Cell = ReplicatedStorage.StatusEvents.CellBlock
Gym = ReplicatedStorage.StatusEvents.GymTime
Shower = ReplicatedStorage.StatusEvents.ShowerTime
Lunch = ReplicatedStorage.StatusEvents.LunchTime
Recreational = ReplicatedStorage.StatusEvents.Recreational
Free = ReplicatedStorage.StatusEvents.FreeTime


local function Cell2()
	Cell.OnServerEvent:Connect(function(player, text1)
		script.Parent.Text = text1
	end)
end

local function Gym2()
	Gym.OnServerEvent:Connect(function(player, text2)
		script.Parent.Text = text2
		end)
end

local function Shower2()
	Shower.OnServerEvent:Connect(function(player, text3)
		script.Parent.Text = text3
	end)
end

local function Free2()
	Free.OnServerEvent:Connect(function(player, text6)
		script.Parent.Text = text6
	end)
end

local function Recreational2()
	Recreational.OnServerEvent:Connect(function(player, text5)
		script.Parent.Text = text5
	end)
end

local function Lunch2()
	Lunch.OnServerEvent:Connect(function(player, text4)
		script.Parent.Text = text4
	end)
end

Gym2()
Cell2()
Shower2()
Free2()
Recreational2()
Lunch2()

Sorry if i made some mistakes. I am new to scripting and this is my first devforum post :slight_smile:. Any help is appreciated.

1 Like
ReplicatedStorage = game:GetService("ReplicatedStorage")
Cell = ReplicatedStorage.StatusEvents.CellBlock
Gym = ReplicatedStorage.StatusEvents.GymTime
Shower = ReplicatedStorage.StatusEvents.ShowerTime
Lunch = ReplicatedStorage.StatusEvents.LunchTime
Recreational = ReplicatedStorage.StatusEvents.Recreational
Free = ReplicatedStorage.StatusEvents.FreeTime
local CellText = "Cell Block Time"
local GymText = "Gym Time"
local ShowerText = "Shower Time"
local LunchText = "Lunch Time"
local RecreationalText = "Recreational"
local FreeText = "Free Time"

local active = {
	CellText = false,
	GymText = false,
	ShowerText = false,
	LunchText = false,
	RecreationalText = false,
	FreeText = false
}

while true do
	if not active.CellText then
		wait(10)
		Cell:FireServer(CellText)	
		active.CellText = true
	elseif not active.GymText then
		wait(240)
		Gym:FireServer(GymText)	
		active.GymText = true
	elseif not active.ShowerText then
		wait(240)
		Shower:FireServer(ShowerText)
		active.ShowerText = true
	elseif not active.LunchText then
		wait(120)
		Lunch:FireServer(LunchText)
		active.LunchText = true
	elseif not active.RecreationalText then
		wait(240)
		Recreational:FireServer(RecreationalText)
		active.RecreationalText = true
	elseif not active.FreeText then
		wait(360)
		Free:FireServer(FreeText)
		active.FreeText = true
	else
		break		
	end
end

Move the script in the local script to the server script, and replace local function Recreational2() Recreational.OnServerEvent:Connect(function(player, text5) with just a function name (e.g. Recreational. Then, in the timer, call the function instead of firing the remote event

This one didnt work. Trying the next reply now.

This one didnt work either. The same thing happens.

What does your script look like now?

I’d recommend making a server value (maybe using attributes or sting values) which is controlled by one server script and the clients get the info from that value.

2 Likes

Alright I will try that and let you know very soon.

Thank you very much this worked!

1 Like