Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is this not appearing on my text label, and why is it client sided?

Asked by 3 years ago

Right so, I have a semi "intermission" script where there is a value that is server sided that goes from 40 - 0 when it is 0 it has a wait where players can enter a solid door that when the value hits 0 will make the door walkable through, my problem is, where the value is displayed on text label it is only client sided. The countdown on the text label goes from 40 to 0 with a 1-second wait, it is looped, it then displays "go through the doors" has a wait, does a few other actions that include another countdown from 80, etc. The whole thing is in a loop. My problem is that when I joined with a test account, the countdown on the text label, not the IntValue, the countdown was client sided not server-sided. E.g When I would join it would automatically countdown from 40, and when he joined a few seconds later, when the count is not on "20" for my screen, would be like "38" for his screen. However, the door int value was still working as after 40 sec it would open. Even though it would still be like "20 Seconds till opening doors" yet the door would open because the countdown is at 0 for my screen. To fix this I did in a loop "Text label is equal to the value" - with a wait (0.01) sec so the "While true do" loop would keep checking, yet that didn't work, the timer just froze, not displaying the value as it went from 40 - 0, my code is below.

TEXT LABEL CODE: - IN A LOCAL SCRIPT UNDER StarterGUI.IntermissionGui.TextIntermission.LocalScript

local gui = game:GetService('Players').LocalPlayer:WaitForChild('PlayerGui')



while true do
    wait(0.01)
    gui.IntermissionGui.Intermission.TextIntermission.Text = game.Workspace.GameStatus.DoorsOpen.Value
end

THE INTVALUE named "DoorValue" is in game.Workspace.GameStatus.DoorsOpen.Value" yet the script to it is in serverscriptservice, the code:

local Value = game.Workspace.GameStatus.DoorsOpen.Value
Value = 40

while true do
    if Value == 40 then
        repeat
            wait(1)
            Value = Value -1
            print(Value)
        until Value == 0
    end


    if Value == 0 then
        print("Doors open")
        game.Workspace.DoorOpen.CanCollide = false
        game.Workspace.DoorOpening.CanCollide = false
        wait(10)
        game.Workspace.DoorOpen.CanCollide = true
        game.Workspace.DoorOpening.CanCollide = true
        print("Doors closed")
        Value = 80
        print("Set Value to 80, RED LIGHT GREEN LIGHT HAS BEGUN")
        repeat 
            wait(1)
            Value = Value -1
        until Value == -1 

        if Value == -1 then
            wait(3)
            Value = 40
        end
    end
end

any help would be great, preferably respond here or at discord, I am JasonAcev#3745

Answer this question