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 » Scripters
Home Search
 

Re: Why won't this script work

Previous Thread :: Next Thread 
TheHolyEpicPenguin is not online. TheHolyEpicPenguin
Joined: 09 Nov 2011
Total Posts: 2718
18 Aug 2016 10:19 AM
--Item spawning script by TheHolyEpicPenguin

--The Item(s)
beans = game.ReplicatedStorage.Beans --The first model you want to spawn
backup1 = beans:clone()
sprite = game.ReplicatedStorage.Sprite --The second model you want to spawn
backup2 = sprite:clone()
--Spawn location
spawner = game.Workspace.BeanSpawn --The spawn location
--Configuration
config = script.Parent.Config --The configuration folder
Lreload = config.minreload.Value --Minimun reload time
Mreload = config.maxreload.Value --Maximum reload time

while true do
wait(.25)
local modelcorrect = math.random(1,2)
if modelcorrect == 1 then
local reload = math.random(Lreload, Mreload)
model1 = beans:clone()
model1.Name = "Bean1"
model1.Parent = game.Workspace
model1.Handle.CFrame = CFrame.new(spawner.Position)
wait(reload)
end
else if modelcorrect == 2 then
local reload = math.random(Lreload, Mreload)
model2 = sprite:clone()
model2.Name = "Sprite1"
model2.Parent = game.Workspace
model2.Handle.CFrame = CFrame.new(spawner.Position)
wait(reload)
end

for the "else", it says "expected 'end' (to close 'do' at line 15), got 'else'
I want to make it so that if the math.random picks 2, then the Sprite will spawn
Report Abuse
WrightPhillips99 is not online. WrightPhillips99
Joined: 27 Jun 2015
Total Posts: 667
18 Aug 2016 10:22 AM
boy u r literally missing an end for the while true do function
Report Abuse
WrightPhillips99 is not online. WrightPhillips99
Joined: 27 Jun 2015
Total Posts: 667
18 Aug 2016 10:23 AM
beans = game.ReplicatedStorage.Beans --The first model you want to spawn
backup1 = beans:clone()
sprite = game.ReplicatedStorage.Sprite --The second model you want to spawn
backup2 = sprite:clone()
--Spawn location
spawner = game.Workspace.BeanSpawn --The spawn location
--Configuration
config = script.Parent.Config --The configuration folder
Lreload = config.minreload.Value --Minimun reload time
Mreload = config.maxreload.Value --Maximum reload time

while true do
wait(.25)
local modelcorrect = math.random(1,2)
if modelcorrect == 1 then
local reload = math.random(Lreload, Mreload)
model1 = beans:clone()
model1.Name = "Bean1"
model1.Parent = game.Workspace
model1.Handle.CFrame = CFrame.new(spawner.Position)
wait(reload)
end
else if modelcorrect == 2 then
local reload = math.random(Lreload, Mreload)
model2 = sprite:clone()
model2.Name = "Sprite1"
model2.Parent = game.Workspace
model2.Handle.CFrame = CFrame.new(spawner.Position)
wait(reload)
end
end
fixed version
Report Abuse
TheHolyEpicPenguin is not online. TheHolyEpicPenguin
Joined: 09 Nov 2011
Total Posts: 2718
18 Aug 2016 10:29 AM
^ NOT fixed

for the "else", it says "expected 'end' (to close 'do' at line 12), got 'else'


again
Report Abuse
WrightPhillips99 is not online. WrightPhillips99
Joined: 27 Jun 2015
Total Posts: 667
18 Aug 2016 10:30 AM
elseif is supposed to be together
Report Abuse
WrightPhillips99 is not online. WrightPhillips99
Joined: 27 Jun 2015
Total Posts: 667
18 Aug 2016 10:32 AM
just try adding ends and taking off ends see what happens or u didn't close a function or statement the right way.
Report Abuse
TheHolyEpicPenguin is not online. TheHolyEpicPenguin
Joined: 09 Nov 2011
Total Posts: 2718
18 Aug 2016 10:35 AM
^ very helpful .-.
Report Abuse
WrightPhillips99 is not online. WrightPhillips99
Joined: 27 Jun 2015
Total Posts: 667
18 Aug 2016 10:36 AM
Thank you for your admiration and if it was sarcasm I had a feeling in my soul.
Report Abuse
TheHolyEpicPenguin is not online. TheHolyEpicPenguin
Joined: 09 Nov 2011
Total Posts: 2718
18 Aug 2016 10:38 AM
I got the script to work:

beans = game.ReplicatedStorage.Beans --The first model you want to spawn
backup1 = beans:clone()
sprite = game.ReplicatedStorage.Sprite --The second model you want to spawn
backup2 = sprite:clone()
--Spawn location
spawner = game.Workspace.BeanSpawn --The spawn location
--Configuration
config = script.Parent.Config --The configuration folder
Lreload = config.minreload.Value --Minimun reload time
Mreload = config.maxreload.Value --Maximum reload time

while true do
wait(.25)
local modelcorrect = math.random(1,2)
if modelcorrect == 1 then
local reload = math.random(Lreload, Mreload)
model1 = beans:clone()
model1.Name = "Bean1"
model1.Parent = game.Workspace
model1.Handle.CFrame = CFrame.new(spawner.Position)
wait(reload)
end
if modelcorrect == 2 then
local reload = math.random(Lreload, Mreload)
model2 = sprite:clone()
model2.Name = "Sprite1"
model2.Parent = game.Workspace
model2.Handle.CFrame = CFrame.new(spawner.Position)
wait(reload)
end
end

I just removed the "else" before the "if"
Report Abuse
WrightPhillips99 is not online. WrightPhillips99
Joined: 27 Jun 2015
Total Posts: 667
18 Aug 2016 10:42 AM
Cool we did it.
Do I get my robux now? JK.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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