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

How would I make a race checkpoint system?

Asked by 4 years ago
--Spiyder1

local Part = script.Parent

while true do
    if workspace.Start.yes.Value == true
    then
        script.Parent.Transparency = .5
        script.Parent.lastheck.Value = true
        wait(.001)
    end
end

while true do
    if script.Parent.lastheck.Value == true
        then
            local function PlayerTouched(Part)
            print("hit")
            script.Parent.yeso.Value = true
            end

            wait(.001)
            Part.Touched:connect(PlayerTouched)
end

There's the code, I want to make the game see that a player hit a checkpoint so the player can continue the race normally (think vehicle legends racing) but the second checkpoint doesn't appear and I have no idea why. No output errors

(P.S. o at the end of the name stands for one)

Let me know if you have any questions about anything about the code! Thanks!

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

You cannot run two loops at the same time, it's best to use spawn or coroutines (depends on what you plan to do) if you want to do this. The first while loop will continue to run forever, therefore the second while loop never has a chance to be run.

Ad

Answer this question