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
 

Confused

Previous Thread :: Next Thread 
epicpatrick123 is not online. epicpatrick123
Joined: 08 Sep 2010
Total Posts: 15039
09 Jun 2012 05:53 PM
It works fine, but no matter what, it always picks the first map i put in "Maps"
Help?



Maps = {"The Mound","Teh epic","Jaginator Style"}
random = Maps[math.random(1,#Maps)]

while true do
wait(20)
script.map.Value = random
local m = Instance.new("Message")
m.Parent = game.Workspace
m.Text = "Choosing a map.."
wait(5)
m.Text = random.." Has been chosen!"
wait(4)
g = game.Lighting[script.map.Value]:Clone()
g.Parent = game.Workspace
g:MakeJoints()
m.Text = "New round started!"
wait(3)
m:remove()
local pplz = game.Players:GetChildren()
for i = 1,#pplz do
if pplz[i].TeamColor == BrickColor.new("Bright Blue") and pplz[i] ~= nil and pplz[i].Character:FindFirstChild("Torso") ~= nil then-- change to team1's TeamColor
script.Parent.What.Disabled = false
elseif pplz[i].TeamColor == BrickColor.new("Bright red") and pplz[i] ~= nil and pplz[i].Character:FindFirstChild("Torso") ~= nil then--change to team2's TeamColor
script.Parent.What.Disabled = true
end end
wait(50)
local pplz = game.Players:GetChildren()
for i = 1,#pplz do
if pplz[i] ~= nil and pplz[i].Character:FindFirstChild("Torso") ~= nil then
script.Parent.What.Disabled = false
end end

local m = Instance.new("Message")
m.Parent = game.Workspace
m.Text = "Game ends in: 10"
wait(1)
m.Text = "Game ends in: 9"
wait(1)
m.Text = "Game ends in: 8"
wait(1)
m.Text = "Game ends in: 7"
wait(1)
m.Text = "Game ends in: 6"
wait(1)
m.Text = "Game ends in: 5"
wait(1)
m.Text = "Game ends in: 4"
wait(1)
m.Text = "Game ends in: 3"
wait(1)
m.Text = "Game ends in: 2"
wait(1)
m.Text = "Game ends in: 1"
wait(1)
m.Text = "Game ends in: 0"
wait(1)
m.Text = "Game ended!"
wait(4)
game.Workspace[script.map.Value]:remove()
m:remove()
end
Report Abuse
epicpatrick123 is not online. epicpatrick123
Joined: 08 Sep 2010
Total Posts: 15039
09 Jun 2012 07:13 PM
bump, i don't know what went wrong
Report Abuse
epicpatrick123 is not online. epicpatrick123
Joined: 08 Sep 2010
Total Posts: 15039
09 Jun 2012 07:17 PM
help plz
Report Abuse
epicpatrick123 is not online. epicpatrick123
Joined: 08 Sep 2010
Total Posts: 15039
09 Jun 2012 07:24 PM
ugh i don't see a problem!
Report Abuse
epicpatrick123 is not online. epicpatrick123
Joined: 08 Sep 2010
Total Posts: 15039
09 Jun 2012 07:25 PM
nvm
Report Abuse
epicpatrick123 is not online. epicpatrick123
Joined: 08 Sep 2010
Total Posts: 15039
09 Jun 2012 07:47 PM
nvm again still dont work
Report Abuse
epicpatrick123 is not online. epicpatrick123
Joined: 08 Sep 2010
Total Posts: 15039
09 Jun 2012 07:55 PM
plz just one person take a guess on what may be wrong
Report Abuse
thecaptain97 is not online. thecaptain97
Joined: 17 Jun 2010
Total Posts: 4987
09 Jun 2012 07:57 PM
You defined 'random' before the Script started, so that means 'random' will always be the Same value each time. Define random in the loop.
Report Abuse
orca101 is not online. orca101
Joined: 11 Sep 2009
Total Posts: 6624
09 Jun 2012 07:58 PM
This is because the random value is outside of the while loop, therefore once the script runs the value is picked and never changes.

-The Unknown Forumer-
Report Abuse
thecaptain97 is not online. thecaptain97
Joined: 17 Jun 2010
Total Posts: 4987
09 Jun 2012 07:59 PM
Exactly.
Report Abuse
epicpatrick123 is not online. epicpatrick123
Joined: 08 Sep 2010
Total Posts: 15039
09 Jun 2012 08:11 PM
Okay, instead of a message i made it a hint, and now it doesn't work, help?


Maps = {"The Mound","Teh Epic","The Seizure","Lava Map"}


while true do
random = Maps[math.random(1,#4)]
wait(20)
script.map.Value = random
local m = script.Parent.Hint
m.Text = "Choosing a map.."
wait(5)
m.Text = random.." Has been chosen!"
wait(4)
g = game.Lighting[script.map.Value]:Clone()
g.Parent = game.Workspace
g:MakeJoints()
m.Text = "New game started!"
wait(3)
m:remove()
local pplz = game.Players:GetChildren()
for i = 1,#pplz do
if pplz[i].TeamColor == BrickColor.new("Bright Blue") and pplz[i] ~= nil and pplz[i].Character:FindFirstChild("Torso") ~= nil then
script.Parent.What.Disabled = false
elseif pplz[i].TeamColor == BrickColor.new("Bright red") and pplz[i] ~= nil and pplz[i].Character:FindFirstChild("Torso") ~= nil then
script.Parent.What.Disabled = true
end end
wait(50)
local pplz = game.Players:GetChildren()
for i = 1,#pplz do
if pplz[i] ~= nil and pplz[i].Character:FindFirstChild("Torso") ~= nil then
script.Parent.What.Disabled = false
end end

local m = script.Parent.Hint
m.Text = "Game ends in: 10"
wait(1)
m.Text = "Game ends in: 9"
wait(1)
m.Text = "Game ends in: 8"
wait(1)
m.Text = "Game ends in: 7"
wait(1)
m.Text = "Game ends in: 6"
wait(1)
m.Text = "Game ends in: 5"
wait(1)
m.Text = "Game ends in: 4"
wait(1)
m.Text = "Game ends in: 3"
wait(1)
m.Text = "Game ends in: 2"
wait(1)
m.Text = "Game ends in: 1"
wait(1)
m.Text = "Game ends in: 0"
wait(1)
m.Text = "Game ended!"
wait(4)
game.Workspace[script.map.Value]:remove()
m:remove()
end
Report Abuse
epicpatrick123 is not online. epicpatrick123
Joined: 08 Sep 2010
Total Posts: 15039
09 Jun 2012 08:15 PM
bump
Report Abuse
epicpatrick123 is not online. epicpatrick123
Joined: 08 Sep 2010
Total Posts: 15039
09 Jun 2012 08:23 PM
help
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
09 Jun 2012 08:35 PM
I think this would work:

Maps = {"The Mound","Teh Epic","The Seizure","Lava Map"}
while true do
random = Maps[math.random(1,#Maps)]
wait(20)
local m = script.Parent.Hint
m.Text = "Choosing a map.."
wait(5)
m.Text = random.." Has been chosen!"
wait(4)
g = game.Lighting[random]:Clone()
g.Parent = game.Workspace
g:MakeJoints()
m.Text = "New game started!"
wait(3)
m:remove()
local pplz = game.Players:GetChildren()
for i = 1,#pplz do
if pplz[i].TeamColor == BrickColor.new("Bright Blue") and pplz[i] ~= nil and pplz[i].Character:FindFirstChild("Torso") ~= nil then
script.Parent.What.Disabled = false
elseif pplz[i].TeamColor == BrickColor.new("Bright red") and pplz[i] ~= nil and pplz[i].Character:FindFirstChild("Torso") ~= nil then
script.Parent.What.Disabled = true
end end
wait(50)
local pplz = game.Players:GetChildren()
for i = 1,#pplz do
if pplz[i] ~= nil and pplz[i].Character:FindFirstChild("Torso") ~= nil then
script.Parent.What.Disabled = false
end end
local m = script.Parent.Hint
m.Text = "Game ends in: 10"
wait(1)
m.Text = "Game ends in: 9"
wait(1)
m.Text = "Game ends in: 8"
wait(1)
m.Text = "Game ends in: 7"
wait(1)
m.Text = "Game ends in: 6"
wait(1)
m.Text = "Game ends in: 5"
wait(1)
m.Text = "Game ends in: 4"
wait(1)
m.Text = "Game ends in: 3"
wait(1)
m.Text = "Game ends in: 2"
wait(1)
m.Text = "Game ends in: 1"
wait(1)
m.Text = "Game ends in: 0"
wait(1)
m.Text = "Game ended!"
wait(4)
game.Workspace[random]:Destroy()
m:Destroy()
end

† KMXD †
Report Abuse
epicpatrick123 is not online. epicpatrick123
Joined: 08 Sep 2010
Total Posts: 15039
09 Jun 2012 08:42 PM
Thanks KNIGHTMAREXD and everyone else who posted, i now have a better understanding on how to script and have a working script!
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
09 Jun 2012 08:46 PM
No problem.

† KMXD †
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