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

Why is this if statement with the text lable not firing the server?

Asked by 3 years ago
if script.Parent.Text == "5" then

    game.ReplicatedStorage.NextLevelEvent:FireServer()
    print("server fired")
end
1
Is this a local script? CodeWon 181 — 3y
0
yes its a local script. diggerbear1 32 — 3y
0
is it not printing? Omq_ItzJasmin 666 — 3y

2 answers

Log in to vote
0
Answered by
MattVSNNL 620 Moderation Voter
3 years ago
Edited 3 years ago

Try this

local debounce = false

while wait() do
    if deboune == false then
        debounce = true
        if script.Parent.Text == "5" then

             game.ReplicatedStorage.NextLevelEvent:FireServer()
             print("server fired")

            wait(3) -- The amount of time until it fires again
            debounce = false
        end
    end
end
0
That would error, you are firing it too many times Omq_ItzJasmin 666 — 3y
Ad
Log in to vote
0
Answered by
V8ML 0
3 years ago
Edited 3 years ago

I'm sure this should work, what it does is whenever the text is changed, it will check if the text is "5" and if it's 5 then it will fire the event.

script.Parent:GetPropertyChangedSignal("Text"):Connect(function() -- when text is changed
    if script.Parent.Text == "5" then

        game.ReplicatedStorage.NextLevelEvent:FireServer()
        print("server fired")
    end
end)

Answer this question