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: Will not break loop..

Previous Thread :: Next Thread 
Xnite515 is not online. Xnite515
Joined: 18 Feb 2011
Total Posts: 22763
11 Mar 2013 03:12 PM
--[[ XNITE ]]--

deb = false

deb1 = false

local teamcolors = {

SC = BrickColor.new("Bright blue") or BrickColor.new("Bright green"),

Raider = BrickColor.new("Bright red")

}

_G["CP1"] = "nil"

script.Parent.Touched:connect(function(hit)
if deb == false then
deb = true
if hit.Parent:findFirstChild("Humanoid") then
plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
if plr.TeamColor == teamcolors["Raider"] and script.Control.Value == BrickColor.new("Bright blue") then
for i = 60, 0 , -1 do
print((hit.Parent.Torso.Position.magnitude - script.Parent.Position.magnitude))
if (hit.Parent.Torso.Position.magnitude - script.Parent.Position.magnitude) <= 3 then
wait(1)
print(i)
if i == 0 then
_G["CP1"] = "Raiders"
script.Control.Value = BrickColor.new("Bright red")
print(_G["CP1"])
script.Parent.BrickColor = BrickColor.new("Bright red")
script.Parent.SpawnLocation.TeamColor = BrickColor.new("Bright red")
elseif (hit.Parent.Torso.Position.magnitude - script.Parent.Position.magnitude) >= 3 then
break end -- here
end
end
deb = false
elseif plr.TeamColor == teamcolors["SC"] and script.Control.Value == BrickColor.new("Bright red") then
for i = 60, 0 , -1 do
print((hit.Parent.Torso.Position.magnitude - script.Parent.Position.magnitude))
if (hit.Parent.Torso.Position.magnitude - script.Parent.Position.magnitude) <= 3 then
wait(1)
print(i)
if i == 0 then
_G["CP1"] = "SC"
script.Control.Value = BrickColor.new("Bright blue")
print(_G["CP1"])
script.Parent.BrickColor = BrickColor.new("Bright blue")
script.Parent.SpawnLocation.TeamColor = BrickColor.new("Bright blue")
elseif (hit.Parent.Torso.Position.magnitude - script.Parent.Position.magnitude) >= 3 then
break end --HERE
end
end
deb = false
end
end
end
end
end)
Report Abuse
Xnite515 is not online. Xnite515
Joined: 18 Feb 2011
Total Posts: 22763
11 Mar 2013 03:15 PM
if plr.TeamColor == teamcolors["Raider"] and script.Control.Value == BrickColor.new("Bright blue") then
for i = 60, 0 , -1 do
print((hit.Parent.Torso.Position.magnitude - script.Parent.Position.magnitude))
if (hit.Parent.Torso.Position.magnitude - script.Parent.Position.magnitude) <= 3 then
wait(1)
print(i)
if i == 0 then
_G["CP1"] = "Raiders"
script.Control.Value = BrickColor.new("Bright red")
print(_G["CP1"])
script.Parent.BrickColor = BrickColor.new("Bright red")
script.Parent.SpawnLocation.TeamColor = BrickColor.new("Bright red")
elseif (hit.Parent.Torso.Position.magnitude - script.Parent.Position.magnitude) >= 3 then
break end -- here
end
end
deb = false


and

elseif plr.TeamColor == teamcolors["SC"] and script.Control.Value == BrickColor.new("Bright red") then
for i = 60, 0 , -1 do
print((hit.Parent.Torso.Position.magnitude - script.Parent.Position.magnitude))
if (hit.Parent.Torso.Position.magnitude - script.Parent.Position.magnitude) <= 3 then
wait(1)
print(i)
if i == 0 then
_G["CP1"] = "SC"
script.Control.Value = BrickColor.new("Bright blue")
print(_G["CP1"])
script.Parent.BrickColor = BrickColor.new("Bright blue")
script.Parent.SpawnLocation.TeamColor = BrickColor.new("Bright blue")
elseif (hit.Parent.Torso.Position.magnitude - script.Parent.Position.magnitude) >= 3 then
break end --HERE
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
11 Mar 2013 03:36 PM
You have to end the if statement with "if i == 0" first, so that you can hook up the elseif with the corresponding if. Otherwise, it will never check if the distance is ​> 3, until the distance is less than three. This is what your code is like:

    if Distance <= 3 then
      if i == 0 then
      elseif Distance ​>= 3
      end
    end

You want to end the second if first:


    if Distance <= 3 then
      if i == 0 then
      end
    elseif Distance ​>=
    end

¤ ¤ † K M <( •д• )> X D † ¤ ¤
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
11 Mar 2013 03:37 PM
You want to end the second if first:

    if Distance <= 3 then
      if i == 0 then
      end
    elseif Distance ​>= 3
    end

¤ ¤ † K M <( •д• )> X D † ¤ ¤
Report Abuse
Xnite515 is not online. Xnite515
Joined: 18 Feb 2011
Total Posts: 22763
11 Mar 2013 03:48 PM
thank you.

Now am having table problems?

--[[ XNITE ]]--

deb = false

deb1 = false

local spawn = {
script.Parent.SpawnLocation
}

local teamcolors = {

["SC"] = BrickColor.new("Bright blue") -- "or" sentences allowed ok - xnite

["Raider"] = BrickColor.new("Bright red")

}


_G["CP1"] = "nil" --my data is floating -xnite

script.Parent.Touched:connect(function(hit)
if deb == false then
deb = true
if hit.Parent:findFirstChild("Humanoid") then
plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
if plr.TeamColor == teamcolors["Raider"] and script.Control.Value == BrickColor.new("Bright blue") then
for i = 60, 0 , -1 do
print((hit.Parent.Torso.Position.magnitude - script.Parent.Position.magnitude))
if (hit.Parent.Torso.Position.magnitude - script.Parent.Position.magnitude) <= 1.2 then
wait(1)
print(i)
elseif (hit.Parent.Torso.Position.magnitude - script.Parent.Position.magnitude) >= 1.2 then
deb = false
break end
if i == 0 then
_G["CP1"] = "Raiders"
script.Control.Value = BrickColor.new("Bright red")
print(_G["CP1"])
for _,spawns in pairs(spawn:GetChildren()) do
spawns.TeamColor = BrickColor.new("Bright red")
end
script.Parent.BrickColor = BrickColor.new("Bright red")
deb = false
end
end
elseif plr.TeamColor == teamcolors["SC"] and script.Control.Value == BrickColor.new("Bright red") then
for i = 60, 0 , -1 do
print((hit.Parent.Torso.Position.magnitude - script.Parent.Position.magnitude))
if (hit.Parent.Torso.Position.magnitude - script.Parent.Position.magnitude) <= 1.2 then
wait(1)
print(i)
elseif (hit.Parent.Torso.Position.magnitude - script.Parent.Position.magnitude) >= 1.2 then
deb = false
break end
if i == 0 then
_G["CP1"] = "SC"
script.Control.Value = BrickColor.new("Bright blue")
print(_G["CP1"])
script.Parent.BrickColor = BrickColor.new("Bright blue")
for _,spawns in pairs(spawn:GetChildren()) do
spawns.TeamColor = BrickColor.new("Bright blue") -- allies ok
end
deb = false
end
end
end
end
end
end
end)
Report Abuse
Xnite515 is not online. Xnite515
Joined: 18 Feb 2011
Total Posts: 22763
11 Mar 2013 03:49 PM
opps forgot the output:

Line15: '}' expected (to close '{' at line 11) near '='

Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
11 Mar 2013 03:49 PM
Where's line 15?

¤ ¤ † K M <( •д• )> X D † ¤ ¤
Report Abuse
Xnite515 is not online. Xnite515
Joined: 18 Feb 2011
Total Posts: 22763
11 Mar 2013 03:50 PM
nevermind..

am so dumb. I forgot the comma..
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
11 Mar 2013 03:50 PM
Oh.

    local teamcolors = {
    ["SC"] = BrickColor.new("Bright blue"), --Comma here
    ["Raider"] = BrickColor.new("Bright red")
    }

¤ ¤ † K M <( •д• )> X D † ¤ ¤
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