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

Why does my game keep on repeating the same Slab over and over again?

Asked by 5 years ago

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!

0
Try putting RanNum1 and slabChosen inside the for loop. Rheines 661 — 5y
0
Tried it, didn't work unfortunately. TheOnlySmarts 233 — 5y
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. fredfishy 833 — 5y
0
Inside or outside the loop? TheOnlySmarts 233 — 5y
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? TheOnlySmarts 233 — 5y

Answer this question