xboy1999
|
  |
| Joined: 25 Jan 2011 |
| Total Posts: 29 |
|
|
| 10 May 2016 09:01 PM |
Hi all, I'm in need of a script that can delete a certain model anywhere in the game from walking/touching (Not clicking) onto a button. If you can't help, but know of someone who can please point me in their direction!
-Xboy |
|
|
| Report Abuse |
|
|
|
| 10 May 2016 09:09 PM |
It's actually really easy to script. Let me give you some pointers: game.Workspace.Anymodel:remove() --removes the model called Anymodel
Use the code in this wiki for contacting with bricks: http://wiki.roblox.com/index.php?title=Lighting_Parts_on_Fire
That's all you need to know. |
|
|
| Report Abuse |
|
|
xboy1999
|
  |
| Joined: 25 Jan 2011 |
| Total Posts: 29 |
|
|
| 10 May 2016 10:20 PM |
Thank you. This did help some, but I am having some trouble putting my part into the equation as its buried deep inside my game and models any advice?
|
|
|
| Report Abuse |
|
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
|
| 10 May 2016 10:33 PM |
yeah put the script in the model ur removing and have it remove script.Parent and function when game.workspace.bricknamehere is touched
|
|
|
| Report Abuse |
|
|
|
| 10 May 2016 10:58 PM |
| deleting a specific model in the game, or a random model? |
|
|
| Report Abuse |
|
|
xboy1999
|
  |
| Joined: 25 Jan 2011 |
| Total Posts: 29 |
|
|
| 11 May 2016 01:57 PM |
Its a specific model heres my script so far:
function removepart(part) print("Going to delete this part:") print(part.Name) game.Workspace.["Xboy's Tycoon Kit"].Tycoons.["Red Clasher"].PurchasedObjects.Lvl1:remove() --removes the model called Anymodel end touchedPart = game.Workspace.["Xboy's Tycoon Kit"].Tycoons.["Red Clasher"].Buttons.["Buy TH1 - $300"].Head touchedPart.Touched:connect(removepart)
A smart man makes a mistake, learns from it, and never makes that mistake again. But a wise man finds a smart man and learns from him how to avoid the mistake altogether. |
|
|
| Report Abuse |
|
|
|
| 11 May 2016 02:00 PM |
:Destroy() is generally better then :remove() from what I've heard.
~~~Da siggy is OP~~~ |
|
|
| Report Abuse |
|
|
xboy1999
|
  |
| Joined: 25 Jan 2011 |
| Total Posts: 29 |
|
|
| 11 May 2016 02:11 PM |
I could do that but my issue is still trying to put the names inside the string.
game.Workspace.["Xboy's Tycoon Kit"].Tycoons.["Red Clasher"].PurchasedObjects.Lvl1:Destroy()
Do I need to Eliminate all the spaces in between the names of my models?
The part is inside my tycoon kit (Ex. "Xboy's Tycoon Kit") then a model called "Tycoons" then another one called "Red Clasher", then PurchasedObjects and then the actual part. But whenever I try to use the script I posted it just comes up with an error: "Error: (5,16) Expected Identifier, got '[' "
I don't know if this contributes to the problem or not, but "Lvl1" that I'm trying to Remove is an Model with parts in it.
A smart man makes a mistake, learns from it, and never makes that mistake again. But a wise man finds a smart man and learns from him how to avoid the mistake altogether. |
|
|
| Report Abuse |
|
|
|
| 11 May 2016 02:14 PM |
game.Workspace["Xboy's Tycoon Kit"].Tycoons["Red Clasher"].Buttons["Buy TH1 - $300"].Head.Touched:connect(function removepart(part) game.Workspace["Xboy's Tycoon Kit"].Tycoons["Red Clasher"].PurchasedObjects.Lvl1:remove() end)
~~~Da siggy is OP~~~ |
|
|
| Report Abuse |
|
|
|
| 11 May 2016 02:14 PM |
That's your whole script there reduced to three lines.
~~~Da siggy is OP~~~ |
|
|
| Report Abuse |
|
|
|
| 11 May 2016 02:15 PM |
Also I would use Destroy but remove would also work fine here.
game.Workspace["Xboy's Tycoon Kit"].Tycoons["Red Clasher"].Buttons["Buy TH1 - $300"].Head.Touched:connect(function removepart(part) game.Workspace["Xboy's Tycoon Kit"].Tycoons["Red Clasher"].PurchasedObjects.Lvl1:Destroy() end)
~~~Da siggy is OP~~~ |
|
|
| Report Abuse |
|
|
xboy1999
|
  |
| Joined: 25 Jan 2011 |
| Total Posts: 29 |
|
|
| 11 May 2016 02:20 PM |
Thank you for shortening it, but it still doesn't work. It now gives this error: "Error: (1,116) Expected '(' got 'removepart' " Pertaining to this:
game.Workspace["Xboy's Tycoon Kit"].Tycoons["Red Clasher"].Buttons["Buy TH1 - $300"].Head.Touched:connect(function removepart(part) ~~This right here ^^^^^^^^^^
game.Workspace["Xboy's Tycoon Kit"].Tycoons["Red Clasher"].PurchasedObjects.Lvl1:Destroy() end)
A smart man makes a mistake, learns from it, and never makes that mistake again. But a wise man finds a smart man and learns from him how to avoid the mistake altogether. |
|
|
| Report Abuse |
|
|
|
| 11 May 2016 02:21 PM |
game.Workspace["Xboy's Tycoon Kit"].Tycoons["Red Clasher"].Buttons["Buy TH1 - $300"].Head.Touched:connect(function (part) game.Workspace["Xboy's Tycoon Kit"].Tycoons["Red Clasher"].PurchasedObjects.Lvl1:Destroy() end)
~~~Da siggy is OP~~~ |
|
|
| Report Abuse |
|
|
xboy1999
|
  |
| Joined: 25 Jan 2011 |
| Total Posts: 29 |
|
|
| 11 May 2016 02:28 PM |
I'm an idiot...
Thank you for helping me through my phase of ignorance..
Here's the finished script:
script.Parent.Touched:connect(function (part) game.Workspace["Xboy's Tycoon Kit"].Tycoons["Red Clasher"].PurchasedObjects.Lvl1:Destroy() end)
A smart man makes a mistake, learns from it, and never makes that mistake again. But a wise man finds a smart man and learns from him how to avoid the mistake altogether. |
|
|
| Report Abuse |
|
|