|
| 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 |
|
|
|
| 12 Jul 2011 10:27 PM |
| Second page already? Buuuump. |
|
|
| Report Abuse |
|
|
| |
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 12 Jul 2011 11:16 PM |
| I got 1 of the 2 parent capitalization issues :3 |
|
|
| Report Abuse |
|
|
|
| 12 Jul 2011 11:20 PM |
| It still doesn't work. And the remove thingy, is not pointless. |
|
|
| Report Abuse |
|
|
|
| 12 Jul 2011 11:21 PM |
| Woah. Got double nimja'd. Nevermind |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
| |
|
| |
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|