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

Help With Loading In Maps?

Asked by
Scootakip 299 Moderation Voter
9 years ago
gm = game.Workspace.GMstat.Intermission

while true do
ToMapOne = CFrame.new(-2, 20.5, -50)
ToMapTwo = CFrame.new(-27, 69.5, 18)
ToSpawn = CFrame.new(277.5, 1.5, -206.5)
mapc = game.Workspace.MapNum.Value
wait(30)
gm.Name = "Game In Progress"
for i, player in ipairs(game.Players:GetChildren()) do
   if player.Character and player.Character:FindFirstChild("Torso") then
    mapc.Value = (math.random(2))
    if mapc.Value == 1 then
      print(mapc.Value)
      player.Character.Torso.CFrame = ToMapOne + Vector3.new(0, i * 5, 0)
      player.TeamColor = game.Teams["Playing"].TeamColor
        for i, m1 in ipairs(game.Workspace.MapOne:GetChildren()) do
    m1.Transparency = 0
    m1.CanCollide = true
end
        end 
    if mapc.Value == 2 then
        print(mapc.Value)
        player.Character.Torso.CFrame = ToMapTwo + Vector3.new(0, i * 5, 0)
        player.TeamColor = game.Teams["Playing"].TeamColor
        for i, m2 in ipairs(game.Workspace.MapTwo:GetChildren()) do
    m2.Transparency = 0
    m2.CanCollide = true
end
    end 
    end  
end
wait(60)
gm.Name = "Intermission"
for i, m1 in ipairs(game.Workspace.MapOne:GetChildren()) do
    m1.Transparency = 1 
    m1.CanCollide = false
end
for i, m2 in ipairs(game.Workspace.MapTwo:GetChildren()) do
    m2.Transparency = 1 
    m2.CanCollide = false
end
for i, player in ipairs(game.Players:GetChildren()) do
      if player.Character and player.Character:FindFirstChild("Torso") then
           player.TeamColor = game.Teams["Lobby"].TeamColor
           player.Character.Torso.CFrame = ToSpawn + Vector3.new(0, i * 5, 0)
end
     end
end

I'm having a serious issue with this script. Currently I have 2 maps, the map is chosen by math.random, I don't know what exactly is wrong with this but I think it's because different players are getting different numbers, resulting in multiple maps being called to load. Can someone tell me how to fix this? The number that's randomly chosen is then given to an intvalue and then the script goes to the intvalue for what to do, so I'm not sure why it's giving multiple numbers. This issue only happens when there are multiple people BTW.

0
This shouldn't be a localscript, if it is. HungryJaffer 1246 — 9y
0
I also reccomend editing this after reading this: It helps other people understand the script: https://scriptinghelpers.org/blog/clean-and-tidy HungryJaffer 1246 — 9y
0
It's not a local script Scootakip 299 — 9y

Answer this question