Breaking and return script not working

Hi guys, I was experimenting with returns and if statements. There is a problem that I have because the if statement isn’t running

local boolean = true
local part = script.Parent
local breakingpoint = 0
local breakingpointaddition = 1


local function randomizer()
adder = breakingpoint + 1
if boolean == true then

	print("yay")
	while wait(1) do
		print(breakingpoint)
		if breakingpoint >= 10 then
			break
		end

	part.BrickColor = BrickColor.random()
	end
else
print("WHYYY")
	return
end

end
print("LETS GOOOO")

and please correct me if I’ve done something wrong in the script

2 Likes

You dont even call a function

Also it won’t return script itself, only a function, so the print “LETS GOOOO” will still run

(waiting for answer :D)

breakingpoint is never incremented so it’ll never be greater than or equal to 10

1 Like

I forgot it works but I kinda need the breakingpoint variable to work

He don’t even call the function lol

As other person said, yo do not increment it

(Also break doesn’t returns, I think you know)

1 Like

Ok, Forgetting to call the function was kinda stupid cuz I already thought I red it

1 Like

Ok, so in total

  1. You don’t call function
  2. You never increment breakingpoint
  3. Returning in function won’t return script
  4. Optional. You can just check if boolean then, because it will automatically check if its not false or not nil (vise-versa (I think its this word?) if you check if not boolean then aka it will check if its true or something else besides false or nil, In other words it will check if its false or nil)

what do you mean by never incrementing it?

You never add 1 to it (or whatever number you want)

while wait(1) do
		print(breakingpoint)
		if breakingpoint >= 10 then
			break
		end

	part.BrickColor = BrickColor.random()
end

You never add any number to it there, you can fix it by doing this

while wait(1) do
		print(breakingpoint)
		if breakingpoint >= 10 then
			break
		end

	part.BrickColor = BrickColor.random()
        breakingpoint += 1 -- aka breakingpoint  = breakingpoint  + 1
end

By the way, wait() is deprecated (Doesn’t means you can’t use it), so it is better to use task.wait() (Yu put number in () you know)

oh ok, I’ve tried using the “breakingpoint += 1” but it has and unknown value at “+=”

2 Likes

+= should work at Numbers

same as …= works on strings (I think its …=)
(In message it shows as 3 dots, why?)
(Its 2 dots)

Oh my gosh it works now, thank you so much : D

1 Like

true, i just presumed it was a code snippet not whole thing and it was called elsewhere mb

1 Like

I thought that first too, but decided to mention it incase it actually happened
(Or I thought about that after I sent the message, not sure already)

I had the same problem in my old experiment but thanks you too males

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.