Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

[SOLVED BY ME]Code inside function not firing?

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?

1 comment

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

1 answer

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!

This discussion is preserved as it was. New answers, comments, and votes are closed.