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

[SOLVED] How do I prevent this from not loading a map?

Asked by 3 years ago
Edited 3 years ago

The map load works in studio, but in game... When a map change it changes, but when it change again it stops working and just sends out nothing at all. (This is a script for a friend I'm currently making... Belongs in ServerScriptService)

local maps = game.Lighting.Maps:GetChildren() --Where the map belongs and how the script grabs it
local msg = Instance.new("Message")
local Death = game.Workspace.Baseplate

while true do -- a loop
    Death.CanCollide = true -- just incase line 19 fails
    msg.Parent  = game.Workspace
    msg.Text = ("Loading New Map (Same map will occur, I can't prevent that since this randomizes.)")
    wait(7)
    chosenmap = maps[math.random(1,#maps)] -- gets a random map 
    chosenmap:Clone().Parent = workspace -- sets the parent to workspace
    msg:remove()
    Death.CanCollide = false
    for i,v in pairs(game.Players:GetChildren())do
        if v.Character then
            v.Character.Torso.CFrame = workspace:FindFirstChild(chosenmap.Name).Spawn.CFrame -- when map loads, people gets teleported over there (MUST HAVE PART IN MAP NAMED "Spawn"!!!)
    Death.CanCollide = false -- just incase line 13 fails
    wait(100) -- time of the round
    workspace:FindFirstChild(chosenmap.Name):Destroy() -- destroys the map after timer
    Death.CanCollide = true 
    wait(.5)
    end
    end
    end
0
try putting a wait(1) right after the while true loop Lamborghinihurican0 4 — 3y
0
Don't think that'll do anything TheBuliderMC 84 — 3y
0
you need to put wait() for while true do to work. Just put wait() without any number and it will work. Shounak123 461 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago

I think you forgot to publish your place. Click File on the upper left corner, then click Publish To Roblox. In this way, you can make it as it is in the studio.

0
I did publish, The script works for like 2 times and then stops and sends nothing to change the map.. TheBuliderMC 84 — 3y
0
you need to put wait() for while true do to work. Just put wait() without any number and it will work. Shounak123 461 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

Answer by: Shounak123

" you need to put wait() for while true do to work. Just put wait() without any number and it will work"

Answer this question