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

Can anyone help me with this spawn script?(FIXED)

Spawnz = workspace.Spawnz:GetChildren() 

lastSpawn = nil

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        repeat
            curSpawn = Spawnz[math.random(1,#Spawnz)]
        until curSpawn ~= lastSpawn -- Help me here where it says curSpawn is an error on output.
        lastSpawn = curSpawn

        wait() --Make character load then move the torso <--Help meh here.

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

2 comments

1

This is my exact code, spawn renamed to curSpawn, from your previous question. What, as specifically as you can, is not working with this code? Are you getting any Output?

0

Yes I am where I posted Help me here where it says curspawn is an error on the output. On the output it keep saying line 8 is an error or so...

1 answer

You mentioned line 8 errored. The only way for this to happen is if #Spawnz is less than 1 due to the bad interval for the math.random call. If it is exactly one it will cause in infinite loop. You must have at least 2 parts inside workspace.Spawnz.

In other words, put parts into workspace.Spawnz already. What did you think the point was?

1 comment

0

Sorry for after posting it I finally found want made the error but thanks for posting.

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