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

Roblox Studio crashes when random spawning script is run?

Asked by 5 years ago

When I run the game on Roblox studio it crashes. The script is suppose to get a random number and spawn a different part at a random position on the map.

while true do
    local zposition = math.random(64, 64)
    local xposition = math.random(64, 64)
    local yposition = 1


    local number = math.random(1,2)

    if number == 1 then Part1 = game.ServerStorage.Part1:Clone()
        Part1.PrimaryPart.Position = Vector3.new(zposition, xposition, yposition)

        if number == 2 then local number2 = math.random(1,2)
            if number2 == 1 then Part2 = game.ServerStorage.Part2:Clone()
        Part2.PrimaryPart.Position = Vector3.new(zposition, xposition, yposition)

        if number2 == 2 then Part3 = game.ServerStorage.Part3:Clone()
        Part3.PrimaryPart.Position = Vector3.new(zposition, xposition, yposition)
        wait(1)

        end
            end
        end
    end

end
0
Try adding a wait to the loop SulaymanArafat 230 — 5y
0
I've added a wait after the code but Ill try adding one before SpacePuppyMan 31 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

I managed to get it working through trial and error. Thanks for the help!

Ad

Answer this question