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

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

Asked by 5 years ago
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.

0
No problem! User#21908 42 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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!

0
and also because Lua doesn't know grammar xD DeceptiveCaster 3761 — 5y
0
ninja'd again xD OfcPedroo 396 — 5y
0
Now [i] is an unknown global aleandroblingo -35 — 5y
0
Nevermind i fixed THANKS! :) aleandroblingo -35 — 5y
Ad

Answer this question