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

I cant use repeats pls help ,Why wont this work?

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		RaceManager.IntermissionStarted:connect(function()
			
			local intermissionDuration = RaceManager:GetIntermissionDuration()
			
			wait(intermissionDuration / 2)
			pushPlayerName("RACE STARTING SOON", intermissionDuration / 4)
	
			--Random Start Grid Spawn
			local Spawns = workspace.Game.GridLineUp:GetChildren()
			local random = Spawns[math.random(1,#Spawns)]
			
			--Moves the kart if there is a kart in the workspace to the starting grid
			local Class   = game.Workspace.Game.GameSettings.Class.Value
			local Kart = game.Workspace.Game.SpawnedGoKarts:FindFirstChild(player.Name.."'s "..Class)
			
			repeat
				for i = 1, #Spawns do
					if Spawns[i]:FindFirstChild("Occupied").Value == false then do
						warn("NOT OCCUPIED M8")
						if (Kart) then 
							Kart:SetPrimaryPartCFrame(random.CFrame + Vector3.new(0,3,1))
							warn(player.Name.."'s " ..Class.." has been Moved to a starting grid")
						else
							warn("Occupide")
						end
					end
					end
				end
			until not Spawns[i]:FindFirstChild("Occupied").Value == false
		end)
		end)
		end)
		
	end)
end)
end)

I cant use ends it seems like ;/

Basically i want it to keep searching for a free spawn place until its found, as when someone spawns there (Occupide) will be true. Like in a racing game telling the script that the player cannot spawn there with the kart.

1 comment

0

No problem!

1 answer

✓ Accepted answer

The not is evaluated first. All you have to do is use parentheses and you are good to go. Here is an example of the until line:

until not (Spawns[i]:FindFirstChild("Occupied").Value == false)

I hope this helps and have a great day scripting!

4 comments

0

and also because Lua doesn't know grammar xD

0

ninja'd again xD

0

Now [i] is an unknown global

0

Nevermind i fixed THANKS! :)

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