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

My script only teleports me to lobby and not the other players. Fix this please?

Asked by
painzx3 43
10 years ago

So it works fine but at the end of the round it teleports just me.

Red = game.Workspace.Bpos--change to where team1 spawns(red team) Note: use Vector3 cordinates
Blue = game.Workspace.Rpos--change to where team2 spawns(blue team)
lobby = game.Workspace.Lpos-- change the the position of the lobby(where the players go before/after the game)
weapon = game.Lighting["Revolver"]
weapon2 = game.Lighting["Knife"]
Maps ={"Divide"},{"Karachi"}-- change Map1,Map2,Map3 to the name of your maps and put them in Lighting. you can add more just add: ,"another map" after Map3 and so on.
r = Maps[math.random(1,#Maps)]

while true do 
wait(15)-- how long between games.
script.map.Value = r
local m = Instance.new("Message")
m.Parent = game.Workspace
m.Text = "Selecting map..."
wait(5)
m.Text = r.." has been chosen!"
wait(4)
g = game.Lighting[script.map.Value]:Clone()
g.Parent = game.Workspace
g:MakeJoints()
m.Text = "Teleporting players..."
wait(3)
m:remove()
d = weapon:Clone()
c = weapon:Clone()
d2 = weapon2:Clone()
c2 = weapon2:Clone()
local pplz = game.Players:GetChildren()
for i = 1,#pplz do 
if pplz[i].TeamColor == BrickColor.new("Bright red") and pplz[i] ~= nil and pplz[i].Character:FindFirstChild("Torso") ~= nil then-- change to team1's TeamColor
c.Parent = pplz[i].StarterGear
d.Parent = pplz[i].Backpack
c2.Parent = pplz[i].StarterGear
d2.Parent = pplz[i].Backpack
pplz[i].Character.Torso.CFrame = Red.CFrame + Vector3.new(0,i*15,0)
d = weapon:Clone()
c = weapon:Clone()
d2 = weapon2:Clone()
c2 = weapon2:Clone()
elseif pplz[i].TeamColor == BrickColor.new("Bright blue") and  pplz[i] ~= nil and pplz[i].Character:FindFirstChild("Torso") ~= nil then--change to team2's TeamColor
pplz[i].Character.Torso.CFrame = Blue.CFrame + Vector3.new(0,i*15,0)
d.Parent = pplz[i].Backpack
c.Parent = pplz[i].StarterGear
d2.Parent = pplz[i].Backpack
c2.Parent = pplz[i].StarterGear
end end 
wait(15)-- how long each game lasts.
local pplz = game.Players:GetChildren()
for i = 1,#pplz do
if pplz[i] ~= nil and pplz[i].Character:FindFirstChild("Torso") ~= nil then 
--local clean1 = pplz[i].StarterGear:GetChildren()
--clean1[i]:remove()
--local clean2 = pplz[i].Backpack:GetChildren()
--clean2[i]:remove()
pplz[i].Character.Torso.CFrame = lobby.CFrame + Vector3.new(0,i*15,0)
end end

local m = Instance.new("Message")
m.Parent = game.Workspace
m.Text = "The round has ended!"
wait(4)
game.Workspace[script.map.Value]:remove()
--m.Text = winner.." has won!"
m:remove()
end

0
Tab & format your code correct. Use decent naming conventions (instance names are canonically pascal case, "Map" not "map") BlueTaslem 18071 — 10y
0
Is this the fixed version? painzx3 43 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

Your error was in the script. CFrame is not really a variable. line 55 and 56 should say this:

pplz[i].Character.Torso.CFrame = lobby.CFrame.p + Vector3.new(0,i*15,0)
end end

CFrame.p returns the Vector3 value of a CFrame. It only did you because the LocalPlayer is always first when dealing with the players, then it broke when CFrame couldn't be written to. CFrame.p fixes this.

Ad

Answer this question