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: What is wrong with this script?

Previous Thread :: Next Thread 
legobear154 is not online. legobear154
Joined: 08 Nov 2009
Total Posts: 113
14 Jul 2010 07:51 PM
while true do
wave = script.Parent.Stats.CurrentWave.value
waveStats = script.Parent.Waves.Waves:findFirstChild("Wave" ..tostring(wave)).Stats
waveMonsters = waveStats.Monsters.Monsters.Value
for i = 1,#waveMonsters do
enemy = script.Parent.Enemy:clone()
Enemy.Parent = script.Parent.Enemys
Enemy.Position = script.Parent.Enemys.Positions.Start.Position
wait(2)
end

while true do
while true do
if script.Parent.Parent.Parent.GameEnabled == true then break end
wait(2)
end
for i = 1, waveMonsters do
start = script.Parent.Enemys.Positions.StartPosition.Position
e = script.Parent.Enemys:getChildren()
for a = 1, #e do
e[a].Position = UDim.new(0, (start.X.Offset), 0, (start.Y.Offset))
T = script.Parent.Enemys.Positions.Turns:getChildren()
for b = 1,#T do
turn = script.Parent.Enemys.Positions.Turns:findFirstChild("Turn" ..tostring(b))
if (turn~=nil) then
if ((turn.Position.X.Offset) - (e[a].Position.X.Offset)) > 0 and if ((turn.Position.Y.Offset) - (e[a].Position.Y.Offset)) > 0 then
e[a].Position = UDim.new(0, (e[a].Position.X.Offset + 5), 0, (e[a].Position.Y.Offset - 5))
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
else if ((turn.Position.X.Offset) - (e[a].Position.X.Offset)) > 0 and if ((turn.Position.Y.Offset) - (e[a].Position.Y.Offset)) < 0 then
e[a].Position = UDim.new(0, (e[a].Position.X.Offset + 5), 0, (e[a].Position.Y.Offset + 5))
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
else if ((turn.Position.X.Offset) - (e[a].Position.X.Offset)) > 0 and if ((turn.Position.Y.Offset) - (e[a].Position.Y.Offset)) = 0 then
e[a].Position = UDim.new(0, (e[a].Position.X.Offset + 5), 0, (e[a].Position.Y.Offset))
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
else if ((turn.Position.X.Offset) - [a]e.Position.X.Offset)) < 0 and if ((turn.Position.Y.Offset) - (e[a].Position.Y.Offset)) < 0 then
e[a].Position = UDim.new(0, (e[a].Position.X.Offset - 5), 0, (e[a].Position.Y.Offset + 5))
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
else if ((turn.Position.X.Offset) - [a]e.Position.X.Offset)) < 0 and if ((turn.Position.Y.Offset) - (e[a].Position.Y.Offset)) = 0 then
e[a].Position = UDim.new(0, (e[a].Position.X.Offset - 5), 0, (e[a].Position.Y.Offset))
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
else if ((turn.Position.X.Offset) - [a]e.Position.X.Offset)) < 0 and if ((turn.Position.Y.Offset) - (e[a].Position.Y.Offset)) > 0 then
e[a].Position = UDim.new(0, (e[a].Position.X.Offset - 5), 0, (e[a].Position.Y.Offset - 5))
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
else if ((turn.Position.X.Offset) - [a]e.Position.X.Offset)) = 0 and if ((turn.Position.Y.Offset) - (e[a].Position.Y.Offset)) = 0 then
e[a].Position = UDim.new(0, (e[a].Position.X.Offset), 0, (e[a].Position.Y.Offset))
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
else if ((turn.Position.X.Offset) - e[a].Position.X.Offset)) = 0 and if ((turn.Position.Y.Offset) - (e[a].Position.Y.Offset)) < 0 then
e[a].Position = UDim.new(0, (e[a].Position.X.Offset), 0, (e[a].Position.Y.Offset + 5))
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
else if ((turn.Position.X.Offset) - [a]e.Position.X.Offset)) = 0 and if ((turn.Position.Y.Offset) - (e[a].Position.Y.Offset)) > 0 then
e[a].Position = UDim.new(0, (e[a].Position.X.Offset), 0, (e[a].Position.Y.Offset - 5))
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
end
end
end
end
end
end
end
end
end
repeat
until [a]e.Position = turn.Position
end
end
end
end
wait()
end
wait()
end

output --> Wed Jul 14 20:48:13 2010 - Players.Player.PlayerGui.ScreenGui.MainFrame.Games.Game1.GameScript:26: unexpected symbol near 'if'
Report Abuse
legobear154 is not online. legobear154
Joined: 08 Nov 2009
Total Posts: 113
14 Jul 2010 08:04 PM
Will someone please help me
Report Abuse
lucas668 is not online. lucas668
Joined: 18 Jun 2008
Total Posts: 6183
14 Jul 2010 08:07 PM
Right above where the output said to look:

while true do
while true do


I don't know for sure, but I think this is the problem.
Report Abuse
Blaboblox is not online. Blaboblox
Joined: 12 Sep 2008
Total Posts: 8945
14 Jul 2010 08:08 PM
It's not "and if"; it's just "and"
Report Abuse
ellosss is not online. ellosss
Joined: 15 Mar 2009
Total Posts: 7030
14 Jul 2010 08:08 PM
while true do
while true do?!
Report Abuse
Shobobo99 is not online. Shobobo99
Joined: 30 Dec 2008
Total Posts: 5754
14 Jul 2010 08:08 PM
when in the if statement the "=" signs must be doubled so its == not =
Report Abuse
ellosss is not online. ellosss
Joined: 15 Mar 2009
Total Posts: 7030
14 Jul 2010 08:11 PM
this is a script that you can throw away in the wastebin!
Report Abuse
legobear154 is not online. legobear154
Joined: 08 Nov 2009
Total Posts: 113
14 Jul 2010 08:20 PM
Sorry about all the errors, I just noticed them when I was looking at it after I posted it. My fixed script is

while true do
wave = script.Parent.Stats.CurrentWave.value
waveStats = script.Parent.Waves.Waves:findFirstChild("Wave" ..tostring(wave)).Stats
waveMonsters = waveStats.Monsters.Monsters.Value
for i = 1,#waveMonsters do
enemy = script.Parent.Enemy:clone()
Enemy.Parent = script.Parent.Enemys
Enemy.Position = script.Parent.Enemys.Positions.Start.Position
wait(2)
end

while true do
if script.Parent.Parent.Parent.GameEnabled == true then break end
wait(2)
end
for i = 1, waveMonsters do
start = script.Parent.Enemys.Positions.StartPosition.Position
e = script.Parent.Enemys:getChildren()
for a = 1, #e do
e[a].Position = UDim.new(0, (start.X.Offset), 0, (start.Y.Offset))
T = script.Parent.Enemys.Positions.Turns:getChildren()
for b = 1,#T do
turn = script.Parent.Enemys.Positions.Turns:findFirstChild("Turn" ..tostring(b))
if (turn~=nil) then
if ((turn.Position.X.Offset) - (e[a].Position.X.Offset)) > 0 and ((turn.Position.Y.Offset) - (e[a].Position.Y.Offset)) > 0 then
e[a].Position = UDim.new(0, (e[a].Position.X.Offset + 5), 0, (e[a].Position.Y.Offset - 5))
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
else if ((turn.Position.X.Offset) - (e[a].Position.X.Offset)) > 0 and ((turn.Position.Y.Offset) - (e[a].Position.Y.Offset)) < 0 then
e[a].Position = UDim.new(0, (e[a].Position.X.Offset + 5), 0, (e[a].Position.Y.Offset + 5))
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
else if ((turn.Position.X.Offset) - (e[a].Position.X.Offset)) > 0 and ((turn.Position.Y.Offset) - (e[a].Position.Y.Offset)) == 0 then
e[a].Position = UDim.new(0, (e[a].Position.X.Offset + 5), 0, (e[a].Position.Y.Offset))
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
else if ((turn.Position.X.Offset) - e[a].Position.X.Offset)) < 0 and ((turn.Position.Y.Offset) - (e[a].Position.Y.Offset)) < 0 then
e[a].Position = UDim.new(0, (e[a].Position.X.Offset - 5), 0, (e[a].Position.Y.Offset + 5))
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
else if ((turn.Position.X.Offset) - e[a].Position.X.Offset)) < 0 and ((turn.Position.Y.Offset) - (e[a].Position.Y.Offset)) == 0 then
e[a].Position = UDim.new(0, (e[a].Position.X.Offset - 5), 0, (e[a].Position.Y.Offset))
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
else if ((turn.Position.X.Offset) - e[a].Position.X.Offset)) < 0 and ((turn.Position.Y.Offset) - (e[a].Position.Y.Offset)) > 0 then
e[a].Position = UDim.new(0, (e[a].Position.X.Offset - 5), 0, (e[a].Position.Y.Offset - 5))
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
else if ((turn.Position.X.Offset) - e[a].Position.X.Offset)) == 0 and ((turn.Position.Y.Offset) - (e[a].Position.Y.Offset)) == 0 then
e[a].Position = UDim.new(0, (e[a].Position.X.Offset), 0, (e[a].Position.Y.Offset))
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
else if ((turn.Position.X.Offset) - e[a].Position.X.Offset)) == 0 and ((turn.Position.Y.Offset) - (e[a].Position.Y.Offset)) < 0 then
e[a].Position = UDim.new(0, (e[a].Position.X.Offset), 0, (e[a].Position.Y.Offset + 5))
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
else if ((turn.Position.X.Offset) - e[a].Position.X.Offset)) == 0 and ((turn.Position.Y.Offset) - (e[a].Position.Y.Offset)) > 0 then
e[a].Position = UDim.new(0, (e[a].Position.X.Offset), 0, (e[a].Position.Y.Offset - 5))
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
end
end
end
end
end
end
end
end
end
repeat
until [a]e.Position = turn.Position
end
end
end
end
wait()
end

and the output says --> Wed Jul 14 21:16:23 2010 - Players.Player.PlayerGui.GemCraft.MainFrame.Games.Game1.GameScript:34: 'then' expected near ')'

The script is suppose to make an image button called enemy to move to each position. Kind of like a tower defence game, if you can fix, make me a new one please do, again sorry for the errors it was late at night when I wrote this script and it was in a hurry.
Report Abuse
ellosss is not online. ellosss
Joined: 15 Mar 2009
Total Posts: 7030
14 Jul 2010 08:22 PM
make every 'else if' elseif and remove most of the ends and the repeat at the bottom makes no sence it repeats nothing.
Report Abuse
ellosss is not online. ellosss
Joined: 15 Mar 2009
Total Posts: 7030
14 Jul 2010 08:25 PM
Oh and remove all those ines in between them. that makes it ahrder to read
Report Abuse
legobear154 is not online. legobear154
Joined: 08 Nov 2009
Total Posts: 113
14 Jul 2010 08:26 PM
I did and the output says Wed Jul 14 21:25:46 2010 - Players.Player.PlayerGui.ScreenGui.MainFrame.Games.Game1.Gam:5: attempt to get length of global 'waveMonsters' (a number value)
Wed Jul 14 21:25:46 2010 - Players.Player.PlayerGui.ScreenGui.MainFrame.Games.Game1.GameScr, line 5 stack end
Report Abuse
legobear154 is not online. legobear154
Joined: 08 Nov 2009
Total Posts: 113
14 Jul 2010 08:28 PM
so?
Report Abuse
Blaboblox is not online. Blaboblox
Joined: 12 Sep 2008
Total Posts: 8945
14 Jul 2010 08:29 PM
Remove the '#'
Report Abuse
legobear154 is not online. legobear154
Joined: 08 Nov 2009
Total Posts: 113
14 Jul 2010 08:34 PM
Wed Jul 14 21:31:26 2010 - Players.Player.PlayerGui.GemCraft.MainFrame.Games.Game1.Gam:7: attempt to index global 'Enemy' (a nil value)
Wed Jul 14 21:31:26 2010 - Players.Player.PlayerGui.GemCraft.MainFrame.Games.Game1.GameScr, line 7 stack end

I really dont understand why this happened
Report Abuse
ellosss is not online. ellosss
Joined: 15 Mar 2009
Total Posts: 7030
14 Jul 2010 08:39 PM
while wait() do
wave = script.Parent.Stats.CurrentWave.value
waveStats = script.Parent.Waves.Waves:findFirstChild("Wave" ..tostring(wave)).Stats
waveMonsters = waveStats.Monsters.Monsters.Value
for i = 1,#waveMonsters do
enemy = script.Parent.Enemy:clone()
Enemy.Parent = script.Parent.Enemys
Enemy.Position = script.Parent.Enemys.Positions.Start.Position
wait(2)
end
end
while wait() do
if script.Parent.Parent.Parent.GameEnabled == true then break end
wait(2)
end
for i = 1, waveMonsters do
start = script.Parent.Enemys.Positions.StartPosition.Position
e = script.Parent.Enemys:getChildren()
for a = 1, #e do
e[a].Position = UDim.new(0, (start.X.Offset), 0, (start.Y.Offset))
T = script.Parent.Enemys.Positions.Turns:getChildren()
for b = 1,#T do
turn = script.Parent.Enemys.Positions.Turns:findFirstChild("Turn" ..tostring(b))
if (turn~=nil) then
if ((turn.Position.X.Offset) - (e[a].Position.X.Offset)) > 0 and ((turn.Position.Y.Offset) - (e[a].Position.Y.Offset)) > 0 then
e[a].Position = UDim.new(0, (e[a].Position.X.Offset + 5), 0, (e[a].Position.Y.Offset - 5))
elseif ((turn.Position.X.Offset) - (e[a].Position.X.Offset)) > 0 and ((turn.Position.Y.Offset) - (e[a].Position.Y.Offset)) < 0 then
e[a].Position = UDim.new(0, (e[a].Position.X.Offset + 5), 0, (e[a].Position.Y.Offset + 5))
elseif ((turn.Position.X.Offset) - (e[a].Position.X.Offset)) > 0 and ((turn.Position.Y.Offset) - (e[a].Position.Y.Offset)) == 0 then
e[a].Position = UDim.new(0, (e[a].Position.X.Offset + 5), 0, (e[a].Position.Y.Offset))
elseif ((turn.Position.X.Offset) - e[a].Position.X.Offset)) < 0 and ((turn.Position.Y.Offset) - (e[a].Position.Y.Offset)) < 0 then
e[a].Position = UDim.new(0, (e[a].Position.X.Offset - 5), 0, (e[a].Position.Y.Offset + 5))
elseif ((turn.Position.X.Offset) - e[a].Position.X.Offset)) < 0 and ((turn.Position.Y.Offset) - (e[a].Position.Y.Offset)) == 0 then
e[a].Position = UDim.new(0, (e[a].Position.X.Offset - 5), 0, (e[a].Position.Y.Offset))
elseif ((turn.Position.X.Offset) - e[a].Position.X.Offset)) < 0 and ((turn.Position.Y.Offset) - (e[a].Position.Y.Offset)) > 0 then
e[a].Position = UDim.new(0, (e[a].Position.X.Offset - 5), 0, (e[a].Position.Y.Offset - 5))
elseif ((turn.Position.X.Offset) - e[a].Position.X.Offset)) == 0 and ((turn.Position.Y.Offset) - (e[a].Position.Y.Offset)) == 0 then
e[a].Position = UDim.new(0, (e[a].Position.X.Offset), 0, (e[a].Position.Y.Offset))
elseif ((turn.Position.X.Offset) - e[a].Position.X.Offset)) == 0 and ((turn.Position.Y.Offset) - (e[a].Position.Y.Offset)) < 0 then
e[a].Position = UDim.new(0, (e[a].Position.X.Offset), 0, (e[a].Position.Y.Offset + 5))
elseif ((turn.Position.X.Offset) - e[a].Position.X.Offset)) == 0 and ((turn.Position.Y.Offset) - (e[a].Position.Y.Offset)) > 0 then
e[a].Position = UDim.new(0, (e[a].Position.X.Offset), 0, (e[a].Position.Y.Offset - 5))
end
end
end
end
end
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