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

Anyone please help my spawn script?

Asked by 10 years ago
local Spawnz = Workspace.Spawnz:GetChildren() --Not GetAllChildren

Game.Players.PlayerAdded:connect(function(player)
    local lastSpawn = nil
    player.CharacterAdded:connect(function(character)
        repeat
            local spawn = Spawnz[(math.random(1, #Spawnz)]
        until spawn ~= lastSpawn
        lastSpawn = spawn

        wait() --Let the Character fully load

        character.Torso.CFrame = spawn.CFrame + Vector3.new(0, 3, 0)
    end)
end)

There is an error local spawn = Spawnz[(math.random(1, #Spawnz)] <----right there the ] is an error. On the output it says line 7 is an error. Please help me anyone.

0
Please dont use Spawnz with a z. When scripting it is important to try sticking to proper english so it makes life easier NinjoOnline 1146 — 10y
0
whats the outputs full comment? NinjoOnline 1146 — 10y

1 answer

Log in to vote
-2
Answered by 10 years ago
Spawnz = workspace.Spawnz:GetChildren() --Not GetAllChildren

lastSpawn = nil

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        repeat
            curSpawn = Spawnz[math.random(1,#Spawnz)]
        until curSpawn ~= lastSpawn
        lastSpawn = curSpawn

        wait() --Let the Character fully load

        character.Torso.CFrame = curSpawn.CFrame + Vector3.new(0, 3, 0)
    end)
end)

0
Answers that are just code are not acceptable. Provide an explanation of what you did, WHY you did it, etc. How else will the OP learn? iaz3 190 — 10y
0
Erm...So Yea...So...What is OP? IIxWhiteRobotxII 0 — 10y
Ad

Answer this question