generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Script Breaks Help!

Previous Thread :: Next Thread 
jaminjames24 is not online. jaminjames24
Joined: 17 Apr 2009
Total Posts: 10856
23 Dec 2012 08:57 PM
----------------------------------------[[SETTINGS]]----------------------------------------
--[[]] money1 = 50 --How many points player will get awarded on win? [[]]--
--[[]] money2 = 20 --How many points players will get awarded if serval players wins? [[]]--
--------------------------------------------------------------------------------------------

h = Instance.new("Hint")
h.Parent = game.Workspace
h.Text = ""

RegTeam = Instance.new("Team")
RegTeam.Name = "Players"
RegTeam.TeamColor = BrickColor.new("Medium stone grey")
RegTeam.Parent = game:GetService("Teams")

function round()
cc = 0
c = game.Players:GetChildren()
for num, obj in pairs(c) do
if obj:FindFirstChild("Playing") then
if obj.Playing.Value then
cc = cc + 1
end
end
end
while cc < 2 do
cc = 0
c = game.Players:GetChildren()
for num, obj in pairs(c) do
if obj:FindFirstChild("Playing") then
if obj.Playing.Value then
cc = cc + 1
end
end
end
h.Text = "Atleast 2 players needed to play."
wait(1)
end
h.Text = "New round will start in few seconds. Use this time to buy upgrades."
wait(10)
h.Text = "Getting Map Ready"
wait(3)
m = game.Lighting.Minigames:GetChildren()
mg = m[math.random(1,#m)]
map = mg.Map
map.Parent = game.Workspace
h.Text = ("Ready to Fight?"..mg.Name)
wait(3)
h.Text = "Teleporting players and giving Weapons..."
wait(3)
c = game.Players:GetChildren()
balanced = true
red = 0
blue = 0
if mg.Mode.Value == 3 then
rt = Instance.new("Team")
rt.Parent = game:GetService("Teams")
rt.AutoAssignable = false
rt.TeamColor = BrickColor.new("Bright red")
rt.Name = "Red team"
bt = Instance.new("Team")
bt.Parent = game:GetService("Teams")
bt.AutoAssignable = false
bt.TeamColor = BrickColor.new("Bright blue")
bt.Name = "Blue team"
end
for num, obj in pairs(c) do
if obj then
if obj.Playing.Value and obj.Character:FindFirstChild("Torso") then
if mg.Mode.Value == 3 then
for numm, objj in pairs(mg.Tools:GetChildren()) do
objj:clone().Parent = obj.Backpack
wait()
end
cc = map:GetChildren()
if balanced then
team = math.random(1,2)
if team == 1 then
red = red + 1
obj.TeamColor = BrickColor.new("Bright red")
elseif team == 2 then
blue = blue + 1
obj.TeamColor = BrickColor.new("Bright blue")
end
teles = {}
for nuum, obbj in pairs(cc) do
if team == 1 then
if obbj.Name == "RedTele" then
table.insert (teles, obbj)
end
elseif team == 2 then
if obbj.Name == "BlueTele" then
table.insert (teles, obbj)
end
end
wait()
end
tele = teles[math.random(1,#teles)]
x1 = tele.Position.X-(tele.Size.X/2)
x2 = tele.Position.X+(tele.Size.X/2)
z1 = tele.Position.Z-(tele.Size.Z/2)
z2 = tele.Position.Z+(tele.Size.Z/2)
obj.Character.Torso.CFrame = CFrame.new(math.random(x1,x2),tele.Position.Y+5,math.random(z1,z2))
balanced = false
else
if red < blue then
team = 1
else
team = 2
end
if team == 1 then
red = red + 1
obj.TeamColor = BrickColor.new("Bright red")
elseif team == 2 then
blue = blue + 1
obj.TeamColor = BrickColor.new("Bright blue")
end
teles = {}
for nuum, obbj in pairs(cc) do
if team == 1 then
if obbj.Name == "RedTele" then
table.insert (teles, obbj)
end
elseif team == 2 then
if obbj.Name == "BlueTele" then
table.insert (teles, obbj)
end
end
wait()
end
tele = teles[math.random(1,#teles)]
x1 = tele.Position.X-(tele.Size.X/2)
x2 = tele.Position.X+(tele.Size.X/2)
z1 = tele.Position.Z-(tele.Size.Z/2)
z2 = tele.Position.Z+(tele.Size.Z/2)
obj.Character.Torso.CFrame = CFrame.new(math.random(x1,x2),tele.Position.Y+5,math.random(z1,z2))
balanced = true
end
obj.Character.Humanoid.WalkSpeed = 0
obj.PlayerGui.Play.Alive.Value = true
wait()
else
for numm, objj in pairs(mg.Tools:GetChildren()) do
objj:clone().Parent = obj.Backpack
wait()
end
cc = map:GetChildren()
teles = {}
for nuum, obbj in pairs(cc) do
if obbj.Name == "Tele" then
table.insert (teles, obbj)
end
wait()
end
tele = teles[math.random(1,#teles)]
x1 = tele.Position.X-(tele.Size.X/2)
x2 = tele.Position.X+(tele.Size.X/2)
z1 = tele.Position.Z-(tele.Size.Z/2)
z2 = tele.Position.Z+(tele.Size.Z/2)
obj.Character.Torso.CFrame = CFrame.new(math.random(x1,x2),tele.Position.Y+5,math.random(z1,z2))
obj.Character.Humanoid.WalkSpeed = 0
obj.PlayerGui.Play.Alive.Value = true
wait()
end
end
end
end
h.Text = ("Rules: "..mg.Rules.Value)
wait(5)
h.Text = "Ready.."
wait(1)
h.Text = "Set.."
wait(1)
h.Text = "GO!"
c = game.Players:GetChildren()
for num, obj in pairs(c) do
if obj.PlayerGui.Play.Alive.Value == true then
obj.Character.Humanoid.WalkSpeed = 16
end
wait()
end
wait(1)
if mg.Mode.Value == 1 then
count = 1
repeat
count = count + 1
c = game.Players:GetChildren()
count2 = {}
for num, obj in pairs(c) do
if obj.PlayerGui.Play.Alive.Value then
table.insert (count2,obj)
end
wait()
end
h.Text = ("Time left: "..mg.Time.Value-count)
wait(1)
until count >= mg.Time.Value or #count2 <= 1
if #count2 > 1 then
for num, obj in pairs(count2) do
ccc = obj.Backpack:GetChildren()
for a, b in pairs(ccc) do
b:remove()
wait()
end
ccc = obj.Character:GetChildren()
for a, b in pairs(ccc) do
if b.className == "Tool" then
b:remove()
elseif b.className == "HooperBin" then
b:remove()
end
wait()
end
if obj.Character:FindFirstChild("Torso") then
obj.Character.Torso.CFrame = game.Workspace.Lobby.LobbyPlatform.CFrame + Vector3.new(0,5,0)
end
wait()
end
h.Text = "Multiple players won."
wait(2)
stringz = {}
for num, obj in pairs(count2) do
table.insert (stringz, obj.Name)
wait()
end
h.Text = ("And they are: "..table.concat (stringz,", "))
wait(3)
h.Text = ("Each of them will get "..money2.." points!")
wait(3)
for num, obj in pairs(count2) do
obj.leaderstats.Points.Value = obj.leaderstats.Points.Value + money2
obj.PlayerGui.Play.Alive.Value = false
wait()
end
elseif #count2 == 1 then
ccc = count2[1].Backpack:GetChildren()
for a, b in pairs(ccc) do
b:remove()
wait()
end
ccc = count2[1].Character:GetChildren()
for a, b in pairs(ccc) do
if b.className == "Tool" then
b:remove()
elseif b.className == "HooperBin" then
b:remove()
end
wait()
end
if count2[1].Character:FindFirstChild("Torso") then
count2[1].Character.Torso.CFrame = game.Workspace.Lobby.LobbyPlatform.CFrame + Vector3.new(0,5,0)
end
h.Text = ("The winner was "..count2[1].Name.."!")
wait(3)
h.Text = ("And he will be awarded with "..money1.." points!")
wait(3)
count2[1].leaderstats.Points.Value = count2[1].leaderstats.Points.Value + money1
count2[1].PlayerGui.Play.Alive.Value = false
elseif #count2 == 0 then
h.Text = "In this round no one won. I hope you will have better luck next time."
end
elseif mg.Mode.Value == 2 then
count = 0
won = nil
map.FinishLine.Touched:connect(function(t)
if game.Players:FindFirstChild(t.Parent.Name) then
won = game.Players[t.Parent.Name]
end
end)
repeat
count = count + 1

h.Text = ("Time left: "..mg.Time.Value-count)
wait(1)
until count >= mg.Time.Value or won ~= nil

if won ~= nil then
for num, obj in pairs(game.Players:GetChildren()) do
if obj then
if obj.PlayerGui.Play.Alive.Value then
ccc = obj.Backpack:GetChildren()
for a, b in pairs(ccc) do
b:remove()
wait()
end
ccc = obj.Character:GetChildren()
for a, b in pairs(ccc) do
if b.className == "Tool" then
b:remove()
elseif b.className == "HooperBin" then
b:remove()
end
wait()
end
end
end
if obj.Character:FindFirstChild("Torso") then
obj.Character.Torso.CFrame = game.Workspace.Lobby.LobbyPlatform.CFrame + Vector3.new(0,5,0)
end
wait()
end
h.Text = ("The winner was "..won.Name.."!")
wait(3)
h.Text = ("And he will get awarded with "..money1.." points!")
wait(3)
won.leaderstats.Points.Value = won.leaderstats.Points.Value + money1
won.PlayerGui.Play.Alive.Value = false
else
h.Text = "In this round no one won. I hope you will have better luck next time."
end
elseif mg.Mode.Value == 3 then
count = 1
repeat
count = count + 1
c = game.Players:GetChildren()
count2 = {}
count3 = {}
for num, obj in pairs(c) do
if obj then
if obj.PlayerGui.Play.Alive.Value then
if obj.TeamColor == BrickColor.new("Bright red") then
table.insert (count2,obj)
elseif obj.TeamColor == BrickColor.new("Bright blue") then
table.insert (count3, obj)
end
end
end
wait()
end
h.Text = ("Time left: "..mg.Time.Value-count)
wait(1)
until count >= mg.Time.Value or #count2 <= 0 or #count3 <= 0
if #count2 == #count3 then
for num, obj in pairs(count2) do
ccc = obj.Backpack:GetChildren()
for a, b in pairs(ccc) do
b:remove()
wait()
end
ccc = obj.Character:GetChildren()
for a, b in pairs(ccc) do
if b.className == "Tool" then
b:remove()
elseif b.className == "HooperBin" then
b:remove()
end
wait()
end
if obj.Character:FindFirstChild("Torso") then
obj.Character.Torso.CFrame = game.Workspace.Lobby.LobbyPlatform.CFrame + Vector3.new(0,5,0)
end
wait()
end
for num, obj in pairs(count3) do
ccc = obj.Backpack:GetChildren()
for a, b in pairs(ccc) do
b:remove()
wait()
end
ccc = obj.Character:GetChildren()
for a, b in pairs(ccc) do
if b.className == "Tool" then
b:remove()
elseif b.className == "HooperBin" then
b:remove()
end
wait()
end
if obj.Character:FindFirstChild("Torso") then
obj.Character.Torso.CFrame = game.Workspace.Lobby.LobbyPlatform.CFrame + Vector3.new(0,5,0)
end
wait()
end
h.Text = "There was tie."
wait(2)
stringz = {}
for num, obj in pairs(count2) do
table.insert (stringz, obj.Name)
wait()
end
wait(3)
h.Text = ("Each player will get "..money2.." points!")
wait(3)
for num, obj in pairs(count2) do
obj.leaderstats.Points.Value = obj.leaderstats.Points.Value + money2
obj.PlayerGui.Play.Alive.Value = false
wait()
end
for num, obj in pairs(count3) do
obj.leaderstats.Points.Value = obj.leaderstats.Points.Value + money2
obj.PlayerGui.Play.Alive.Value = false
wait()
end
elseif #count2 > #count3 and #count3 > 0 then
for num, obj in pairs(count2) do
if obj then
ccc = obj.Backpack:GetChildren()
for a, b in pairs(ccc) do
b:remove()
wait()
end
ccc = obj.Character:GetChildren()
for a, b in pairs(ccc) do
if b.className == "Tool" then
b:remove()
elseif b.className == "HooperBin" then
b:remove()
end
wait()
end
if obj.Character:FindFirstChild("Torso") then
obj.Character.Torso.CFrame = game.Workspace.Lobby.LobbyPlatform.CFrame + Vector3.new(0,5,0)
end
wait()
end
for num, obj in pairs(count3) do
ccc = obj.Backpack:GetChildren()
for a, b in pairs(ccc) do
b:remove()
wait()
end
ccc = obj.Character:GetChildren()
for a, b in pairs(ccc) do
if b.className == "Tool" then
b:remove()
elseif b.className == "HooperBin" then
b:remove()
end
wait()
end
if obj.Character:FindFirstChild("Torso") then
obj.Character.Torso.CFrame = game.Workspace.Lobby.LobbyPlatform.CFrame + Vector3.new(0,5,0)
end
end
wait()
end
h.Text = ("The winner was red team!")
wait(3)
h.Text = ("They will get awarded with "..money1.." points, but as some of enemies are still alive, theyr team will get "..money2.." points!")
wait(3)
wait(3)
for num, obj in pairs(count2) do
obj.leaderstats.Points.Value = obj.leaderstats.Points.Value + money1
obj.PlayerGui.Play.Alive.Value = false
wait()
end
for num, obj in pairs(count3) do
obj.leaderstats.Points.Value = obj.leaderstats.Points.Value + money2
obj.PlayerGui.Play.Alive.Value = false
wait()
end
elseif #count2 < #count3 and #count2 > 0 then
for num, obj in pairs(count2) do
ccc = obj.Backpack:GetChildren()
for a, b in pairs(ccc) do
b:remove()
wait()
end
ccc = obj.Character:GetChildren()
for a, b in pairs(ccc) do
if b.className == "Tool" then
b:remove()
elseif b.className == "HooperBin" then
b:remove()
end
wait()
end
if obj.Character:FindFirstChild("Torso") then
obj.Character.Torso.CFrame = game.Workspace.Lobby.LobbyPlatform.CFrame + Vector3.new(0,5,0)
end
wait()
end
for num, obj in pairs(count3) do
ccc = obj.Backpack:GetChildren()
for a, b in pairs(ccc) do
b:remove()
wait()
end
ccc = obj.Character:GetChildren()
for a, b in pairs(ccc) do
if b.className == "Tool" then
b:remove()
elseif b.className == "HooperBin" then
b:remove()
end
wait()
end
if obj.Character:FindFirstChild("Torso") then
obj.Character.Torso.CFrame = game.Workspace.Lobby.LobbyPlatform.CFrame + Vector3.new(0,5,0)
end
wait()
end
h.Text = ("The winner was blue team!")
wait(3)
h.Text = ("They will get awarded with "..money1.." points, but as some of enemies are still alive, theyr team will get "..money2.." points!")
wait(3)
for num, obj in pairs(count2) do
obj.leaderstats.Points.Value = obj.leaderstats.Points.Value + money2
obj.PlayerGui.Play.Alive.Value = false
wait()
end
for num, obj in pairs(count3) do
obj.leaderstats.Points.Value = obj.leaderstats.Points.Value + money1
obj.PlayerGui.Play.Alive.Value = false
wait()
end
elseif #count2 == 0 then
for num, obj in pairs(count3) do
ccc = obj.Backpack:GetChildren()
for a, b in pairs(ccc) do
b:remove()
wait()
end
ccc = obj.Character:GetChildren()
for a, b in pairs(ccc) do
if b.className == "Tool" then
b:remove()
elseif b.className == "HooperBin" then
b:remove()
end
wait()
end
if obj.Character:FindFirstChild("Torso") then
obj.Character.Torso.CFrame = game.Workspace.Lobby.LobbyPlatform.CFrame + Vector3.new(0,5,0)
end
wait()
end
h.Text = ("The winner was blue team!")
wait(3)
h.Text = ("They will get awarded with "..money1.." points!")
wait(3)
for num, obj in pairs(count3) do
obj.leaderstats.Points.Value = obj.leaderstats.Points.Value + money1
obj.PlayerGui.Play.Alive.Value = false
wait()
end
elseif #count3 == 0 then
for num, obj in pairs(count2) do
ccc = obj.Backpack:GetChildren()
for a, b in pairs(ccc) do
b:remove()
wait()
end
ccc = obj.Character:GetChildren()
for a, b in pairs(ccc) do
if b.className == "Tool" then
b:remove()
elseif b.className == "HooperBin" then
b:remove()
end
wait()
end
if obj.Character:FindFirstChild("Torso") then
obj.Character.Torso.CFrame = game.Workspace.Lobby.LobbyPlatform.CFrame + Vector3.new(0,5,0)
end
wait()
end
h.Text = ("The winner was red team!")
wait(3)
h.Text = ("They will get awarded with "..money1.." points!")
wait(3)
for num, obj in pairs(count2) do
obj.leaderstats.Points.Value = obj.leaderstats.Points.Value + money1
obj.PlayerGui.Play.Alive.Value = false
wait()
end
elseif #count2 == 0 then
h.Text = "In this round no one won. I hope you will have better luck next time."
end
loldunno = game.Players:GetChildren()
for olol, trolol in pairs(loldunno) do
trolol.TeamColor = BrickColor.new("Medium stone grey")
wait()
end
rt:remove()
bt:remove()
end
map.Parent = mg
round()
end

round()


Breaks after one team all dies and it just freezes
Report Abuse
jaminjames24 is not online. jaminjames24
Joined: 17 Apr 2009
Total Posts: 10856
23 Dec 2012 08:58 PM
Also i only have one game the Game for Team Sword Fighting
Report Abuse
kungfuman32 is not online. kungfuman32
Joined: 12 Dec 2008
Total Posts: 9172
23 Dec 2012 09:12 PM
Did you make this?
Report Abuse
jaminjames24 is not online. jaminjames24
Joined: 17 Apr 2009
Total Posts: 10856
23 Dec 2012 09:12 PM
Back in 09
Report Abuse
jaminjames24 is not online. jaminjames24
Joined: 17 Apr 2009
Total Posts: 10856
23 Dec 2012 09:13 PM
then some nub copied it
Report Abuse
masta789 is not online. masta789
Joined: 13 Mar 2012
Total Posts: 181
23 Dec 2012 09:43 PM
It Just Broke Me......
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image