#My code isn't working

1 messages · Page 1 of 1 (latest)

snow wind
#

I want a label to display the text stated in a scrips, what am I doing wrong?

Scrpit 1 (LocalScript):

local gameStatus = game.ReplicatedStorage:WaitForChild("GameStatus")
local statusLabel = script.Parent:WaitForChild("StatusLabel")

local function updateLabel()
    
    local status = gameStatus.Value
    statusLabel.Text = status
    
end

gameStatus:GetPropertyChangedSignal("Value"):Connect(updateLabel)

Script 2:

local gameStatus = game.ReplicatedStorage:WaitForChild("GameStatus")

local LobbyCFrame = workspace:WaitForChild("Lobby"):WaitForChild("SpawnLocation").CFrame + Vector3.yAxis+5

local Intermission = 10

while true do
    
    --Intermission
    for countdown = Intermission, 0, -1 do
        
        gameStatus.Value = "Intermission" .. countdown
        task.wait(1)
        
    end
    
    --Choose Minigame
    
    --Run Minigame
    
    --End Minigame
    
end
snow gorge
#

can u show ur explorer

#

also does the gui load in at all

glacial perch
#

not sure how your system works, but you never call updateLabel on first run, so it may not work the first time

snow wind
#

Sorry I couldn't provide it earlier, it was late and I was told to go to sleep by my parents

snow wind
#

I used a loop to call updateLabel every second, but the second code isn't working properly either and doesn't run the Intermission section and I don't know why.

snow gorge
# snow wind I used a loop to call updateLabel every second, but the second code isn't workin...
  1. you dont need to use a while loop to check every frame u should just change the textlabel every time the round changes.

2.you have "GameStatus" in replicated storage which is accessable by both the client and the server (THIS IS VERY VERY VERY VERY VERY VERYYYYYYYYYYYYY BAD) since exploiters can change this value and mess with the game.

3.For me personally I dont like using embedded local scripts in gui since it can get messy but its fine for small projects.

Solution: Ok so the server should be in control of the round status. When the server changes the round status it should send a remote event to all clients to tell them to change their gui. (also keep gamestatus in serverstorage not replicated) see if that works......

snow wind
#

Alright, thanks

vestal parcelBOT
#

studio** You are now Level 1! **studio

glacial perch
#

Also use ReplicatedStorage if you want to display the status on a UI, clients can’t access ServerStorage

#

If you’re not displaying it use SS