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

[SOLVED BY ME]Code inside function not firing?

Asked by 4 years ago
Edited 4 years ago

I have been working on this piece of code, and I've come accross a bug, I believe. Here's the script.

local CompletedStage3 = false
script.Parent.Text = " "
Humanoid.WalkSpeed = 16
Humanoid.JumpPower = 50
workspace.Stage3KeycardPart.Success.Changed:Connect(function()
    if workspace.Stage3KeycardPart.Success.Value == true then
        CompletedStage3 = true
        for i = 1,#SuccessStage3 do
            script.Parent.Text = string.sub(SuccessStage3,1,i)
            workspace.Typing:Play()
            wait()
        end
    else
        CompletedStage3 = true
        for i = 1,#FailureStage3 do
            script.Parent.Text = string.sub(FailureStage3,1,i)
            workspace.Typing:Play()
            wait()
        end
    end
end)
if CompletedStage3 == true then
    print("completed")
end

It is supposed to work, and it shows nothing in the output. No warnings, errors or prints. Any help please?

0
Have you done any print testing(should do when having problems around if statements)...its hard for me to help you when I dont know the value of stage3keycardpart ForeverBrown 356 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Oops! Sorry. Apparently the value of Success actually affected the script. The value's default value was actually set to false, so the script didn't find a change when the math.random chose 1, or failure. I fixed it using another value within the Stage3Keycardpart called Failure. This way, I can see if the player failed or not. Thank you for replying anyways!

Ad

Answer this question