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

How would I make a race checkpoint system?

--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

✓ Accepted answer

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.

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