So, I'm making a game, ColourSink, I've fixed other issues in the game, like lerping and BodyPositions. But this one is just frustrating. Even with proper scripting, this keeps on repeating the same Slab over and over again.

I want it so it chooses a different Slab every time the minigame repeats but instead, it does this, over and over.

https://i.gyazo.com/9a3eb10e0e22a9a9f5038393e1db08c4.mp4

But it basically chooses the same colour over and over.

Thing is, I think my scripting is right.

Here is my scripting, it looks correct to me, but what do I know. I'm still a beginner.

function colourS()
	slabs = game.Workspace.ColourSink.Slabs:GetChildren()
	ranNum1 = math.random(1, #slabs)
	slabChosen = slabs[ranNum1]
		for i = 0, 1, 0.5 do
   			game.Workspace.ColourSink.Billboard.Part.SurfaceGui.TextLabel.Text = slabChosen.Colour.Value
       		wait(2)
			slabChosen.CFrame = slabChosen.CFrame:lerp(slabChosen.endpart.CFrame, 0.5)
        	wait(4)
       		slabChosen.CFrame = slabChosen.CFrame:lerp(slabChosen.startpart.CFrame, 1)
			game.Workspace.ColourSink.Billboard.Part.SurfaceGui.TextLabel.Text = "Colour"
		wait()
	end
end

This is the best I can get the format to, sorry.

Any help would be appreciated, thank you!

5 comments

0

Try putting RanNum1 and slabChosen inside the for loop.

0

Tried it, didn't work unfortunately.

0

Remove ranNum1. Replace slabs[ranNum1] with slabs[math.random(1, #slabs)]. Setting a variable to the result of math.random is like setting it to the result of a dice roll, not the act of rolling the dice itself.

0

Inside or outside the loop?

0

Omg thank you so much!!! Only problem now is that the timer at the top isn't going down, just staying at 29? Should I add u on discord to explain easier?