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: Help with cloning script

Previous Thread :: Next Thread 
Chiefwaffles is not online. Chiefwaffles
Joined: 02 Nov 2009
Total Posts: 1138
12 Jul 2011 10:14 PM
I'm making some objects that I can insert a game. And One thing I'm making is a "Sammich Maker". Which would clone a sammich, delete it. THen when a button is clicked, it spawns a sammich at a non can-collide brick and the sammich would fall down to the table. However I'm having problems with the script. When I test it, the sammich which is supposed to be deleted just sits on top of the non can-collide brick doing nothing.

The tree goes like this:

Model
--Healthy_Sammich
--Button
----ClickDetector
----Script
--Spawner

..And the script:

--Clone the Sammich for further use
local backup = script.parent.Healthy_Sammich:clone()
--Remove the Sammich because we don't need it anymore.
script.parent.Healthy_Sammich:remove()
--Place the Sammich
function onClicked()
model = backup:clone()
model.parent = game.workspace
script.Parent.ClickDetector.MouseClick:connect (onClicked)
________

Thanks for helping.
Report Abuse
Chiefwaffles is not online. Chiefwaffles
Joined: 02 Nov 2009
Total Posts: 1138
12 Jul 2011 10:27 PM
Second page already? Buuuump.
Report Abuse
Chiefwaffles is not online. Chiefwaffles
Joined: 02 Nov 2009
Total Posts: 1138
12 Jul 2011 11:10 PM
Second Page again. Aaagh.
Report Abuse
chikenugget is not online. chikenugget
Joined: 09 May 2009
Total Posts: 2552
12 Jul 2011 11:12 PM
--Clone the Sammich for further use
backup = script.parent.Healthy_Sammich:clone()
--Remove the Sammich because we don't need it anymore.
script.parent.Healthy_Sammich:remove() --pointless much?
--Place the Sammich
function onClicked()
model = backup:clone()
model.Parent = game.workspace
script.Parent.ClickDetector.MouseClick:connect (onClicked)
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
12 Jul 2011 11:14 PM


"local backup = script.parent.Healthy_Sammich:clone()"

2 problems in this line:

first, you must capitalize the first letter of parent, so it should be 'Parent' instead of 'parent'.

Also, if you didn't notice, the "sammich" isn't in the script's parent, it is in the parent of the script's parent.

There were also some other errors, like when you used game.workspace.

You can use workspace, Workspace or game.Workspace, but you can't use game.workspace.

Fixed version:

--Clone the Sammich for further use
local backup = script.Parent.Parent.Healthy_Sammich:Clone()
--Remove the Sammich because we don't need it anymore.
script.Parent.Parent.Healthy_Sammich:Remove()
--Place the Sammich
local function onClicked()
local model = backup:Clone()
model.Parent = Workspace
script.Parent.ClickDetector.MouseClick:connect (onClicked)
Report Abuse
chikenugget is not online. chikenugget
Joined: 09 May 2009
Total Posts: 2552
12 Jul 2011 11:16 PM
I got 1 of the 2 parent capitalization issues :3
Report Abuse
Chiefwaffles is not online. Chiefwaffles
Joined: 02 Nov 2009
Total Posts: 1138
12 Jul 2011 11:20 PM
It still doesn't work. And the remove thingy, is not pointless.
Report Abuse
Chiefwaffles is not online. Chiefwaffles
Joined: 02 Nov 2009
Total Posts: 1138
12 Jul 2011 11:21 PM
Woah. Got double nimja'd. Nevermind
Report Abuse
Chiefwaffles is not online. Chiefwaffles
Joined: 02 Nov 2009
Total Posts: 1138
12 Jul 2011 11:35 PM
Julien, your script doesn't work. The sammich still just sits on top of the spawner, doing nothing, from right when I start up the test thingy.
Report Abuse
Chiefwaffles is not online. Chiefwaffles
Joined: 02 Nov 2009
Total Posts: 1138
13 Jul 2011 12:50 AM
Oh. I'm a idiot. I forgot an end. It now clones and deletes it properly, but the button doesn't seem to be working. More help, Please? =3
Current script is this:

--Clone the Sammich for further use
local backup = script.Parent.Parent.Healthy_Sammich:Clone()
--Remove the Sammich because we don't need it anymore.
script.Parent.Parent.Healthy_Sammich:Remove()
--Place the Sammich
local function onClicked()
local model = backup:Clone()
model.Parent = Workspace
script.Parent.ClickDetector.MouseClick:connect (onClicked)
end

Anyone know whats wrong now?
Also, I haven't scripted in 2-3 months. So I frequently forget the small things.
Report Abuse
Chiefwaffles is not online. Chiefwaffles
Joined: 02 Nov 2009
Total Posts: 1138
13 Jul 2011 01:05 AM
Ok. So I just added prints after every step, and ended up with this:

--Clone the Sammich for further use
local backup = script.Parent.Parent.Healthy_Sammich:Clone()
print("Made a Sammich Backup!")
--Remove the Sammich because we don't need it anymore.
script.Parent.Parent.Healthy_Sammich:Remove()
print("Removed Sammich!")
--Place the Sammich
local function onClicked()
print("Got clicked!")
local model = backup:Clone()
print("Got a clone of backup!")
model.Parent = Workspace
script.Parent.ClickDetector.MouseClick:connect (onClicked)
print("Sammich Maker worked!")
end

It gets "Made a sammich backup" and "Removed Sammich" when I start up roblox, like I want it to. BUT. I don't get any output when I try clicking. Nothing I tried works. Help? Please?!
Report Abuse
Chiefwaffles is not online. Chiefwaffles
Joined: 02 Nov 2009
Total Posts: 1138
13 Jul 2011 12:18 PM
..Help?
Report Abuse
Chiefwaffles is not online. Chiefwaffles
Joined: 02 Nov 2009
Total Posts: 1138
13 Jul 2011 01:55 PM
*Sigh*
Report Abuse
Chiefwaffles is not online. Chiefwaffles
Joined: 02 Nov 2009
Total Posts: 1138
13 Jul 2011 02:17 PM
Come on, people. YOu have all the information you can possibly get. At least reply with what you THINK would fix it?
Report Abuse
ElectricAxel is not online. ElectricAxel
Joined: 15 May 2009
Total Posts: 16239
13 Jul 2011 02:18 PM
._.

--Clone the Sammich for further use
local backup = script.parent.Healthy_Sammich:clone()
--Remove the Sammich because we don't need it anymore.
script.Parent.Healthy_Sammich:remove()
--Place the Sammich
function onClicked()
model = backup:clone()
model.Parent = workspace
end
script.Parent.ClickDetector.MouseClick:connect (onClicked)
Report Abuse
Chiefwaffles is not online. Chiefwaffles
Joined: 02 Nov 2009
Total Posts: 1138
13 Jul 2011 02:27 PM
Your script doesn't work. BUT, It made me notice I forgot to put the connect line after the end. See? Always little things.

Thanks alot everyone.
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