HAPPYBOY
|
  |
| Joined: 08 Oct 2007 |
| Total Posts: 585 |
|
|
| 03 Jun 2012 10:46 PM |
Problem: Script is deleting URFCMechClone reguardless of weither the model is in the location or not. No errors btw.
function check() if enabled == true then enabled = false wait(0.5) if (URFCMechClone.Parent == script.Parent.Parent) ~= nil then regenerate() elseif (URFCMechClone.Parent == script.Parent.Parent) == nil then URFCMechClone:Remove() regenerate() end elseif enabled == false then end end |
|
|
| Report Abuse |
|
|
HAPPYBOY
|
  |
| Joined: 08 Oct 2007 |
| Total Posts: 585 |
|
|
| 03 Jun 2012 10:48 PM |
Sorry that should be like this.
function check() if enabled == true then enabled = false wait(0.5) if (URFCMechClone.Parent == script.Parent.Parent) ~= nil then URFCMechClone:Remove() regenerate() elseif (URFCMechClone.Parent == script.Parent.Parent) == nil then regenerate() end elseif enabled == false then end end |
|
|
| Report Abuse |
|
|
|
| 03 Jun 2012 10:49 PM |
Remove the ~= nil and then == nil, it returns true or false. -.-
function check() if enabled == true then enabled = false wait(0.5) if (URFCMechClone.Parent == script.Parent.Parent) then regenerate() elseif (URFCMechClone.Parent ~= script.Parent.Parent) then URFCMechClone:Remove() regenerate() end elseif enabled == false then end end
PS: Who isn't teaching data types ...? |
|
|
| Report Abuse |
|
|
|
| 03 Jun 2012 10:50 PM |
Does the "regenerate" function happen to Remove it?
Also, having "if enabled == false then" at the Bottom won't do anything, and Remove() has been Depreciated, use Destroy() |
|
|
| Report Abuse |
|
|
HAPPYBOY
|
  |
| Joined: 08 Oct 2007 |
| Total Posts: 585 |
|
|
| 03 Jun 2012 10:51 PM |
| Lawl thanks. Sorry bud, I am from 07 and I stopped doing Lua scripting a year ago and converted to Java, I am just now returning to Lua. Thanks! |
|
|
| Report Abuse |
|
|
|
| 03 Jun 2012 10:59 PM |
| I just fixed what caught my attention the most, there are still some other errors I hope you can fix now. x_x |
|
|
| Report Abuse |
|
|
HAPPYBOY
|
  |
| Joined: 08 Oct 2007 |
| Total Posts: 585 |
|
|
| 03 Jun 2012 11:13 PM |
It's still not doing what I ask it to. It's contining it's problem. Help please?
|
|
|
| Report Abuse |
|
|
|
| 03 Jun 2012 11:14 PM |
Enabled = true function check() if enabled == true then enabled = false wait(0.5) if (URFCMechClone.Parent == script.Parent.Parent) then regenerate() elseif (URFCMechClone.Parent ~= script.Parent.Parent) then URFCMechClone:Remove() regenerate() end enabled = true end end
|
|
|
| Report Abuse |
|
|
HAPPYBOY
|
  |
| Joined: 08 Oct 2007 |
| Total Posts: 585 |
|
|
| 03 Jun 2012 11:21 PM |
| Okay so, enabled is returned to true in the regenerate function so that didn't need to be changed. And enable was already set to true further up the script. |
|
|
| Report Abuse |
|
|
|
| 03 Jun 2012 11:22 PM |
| Was just making sure. Other than that this part of the script seems to be fine. Is there some event it should be connected to? Any output you can share with us? |
|
|
| Report Abuse |
|
|
HAPPYBOY
|
  |
| Joined: 08 Oct 2007 |
| Total Posts: 585 |
|
|
| 03 Jun 2012 11:31 PM |
I was just about to paste the entire script so you would be able to review it but then I found the problem at the very very bottem... This is one of those times when you feel really dumb because it was a very simple problem but you made it into a huge mess that took over an hour or two trying to fix.
I had
script.Parent.ClickDetector.MouseClick:connect(regenerate)
Instead of
script.Parent.ClickDetector.MouseClick:connect(check)
So it was ignoring the function like I said, but because I never told it to go though check instead of directly regenerating... Derp! Hope this put a smile on your face :D |
|
|
| Report Abuse |
|
|
|
| 03 Jun 2012 11:35 PM |
| I've been there myself, so yeah, I can relate. xP But next time try showing the whole thing instead of just a part, that way we might notice even more things. o: |
|
|
| Report Abuse |
|
|
HAPPYBOY
|
  |
| Joined: 08 Oct 2007 |
| Total Posts: 585 |
|
|
| 03 Jun 2012 11:38 PM |
Right when I think every problem is solved... I find one more small issue. It's supposed to only regen if enabled is true but it seems regen anyway. So here you are ladies and gentleman! The legendary script lol.
--Scripted By Happyboy (June 3rd, 2012)-- local Main = script.Parent.Parent.Mech local MechClone = Main:Clone() local enabled = true
Main:Remove() URFCMechClone = MechClone:clone() URFCMechClone.Parent = script.Parent.Parent URFCMechClone:makeJoints()
function check() if enabled == true then local enabled = false wait(0.5) if (URFCMechClone.Parent ~= script.Parent.Parent) then regenerate() elseif (URFCMechClone.Parent == script.Parent.Parent) then URFCMechClone:Remove() regenerate() end end end
function regenerate() script.Parent.BrickColor = BrickColor.new(26) URFCMechClone = MechClone:clone() URFCMechClone.Parent = script.Parent.Parent URFCMechClone:makeJoints() wait(10) local enabled = true script.Parent.BrickColor = BrickColor.new(104) end
script.Parent.ClickDetector.MouseClick:connect(check) |
|
|
| Report Abuse |
|
|
|
| 03 Jun 2012 11:45 PM |
| Remove the local from the enabled inside the functions, it will fix the problem. |
|
|
| Report Abuse |
|
|
HAPPYBOY
|
  |
| Joined: 08 Oct 2007 |
| Total Posts: 585 |
|
|
| 03 Jun 2012 11:51 PM |
| Umm, well that did fix it. But I am confused, why did that cause a problem? I never used to have problems doing that in 09. |
|
|
| Report Abuse |
|
|
|
| 03 Jun 2012 11:54 PM |
To make it simple, and true but not quite accurate, local makes those variables only exist inside that function:
a = "Hello!" print(a) function change() local a = "I changed D:" print("In then function, a = ", a) end change() print("After function, a = ", a)
Try that script. |
|
|
| Report Abuse |
|
|
HAPPYBOY
|
  |
| Joined: 08 Oct 2007 |
| Total Posts: 585 |
|
|
| 03 Jun 2012 11:57 PM |
| Wow, I never knew that in all my days in Roblox. Thank you! I have learned something today :D |
|
|
| Report Abuse |
|
|