Zakusa
|
  |
| Joined: 16 Feb 2013 |
| Total Posts: 359 |
|
|
| 17 Sep 2015 08:35 PM |
| hi i need help with getting localplayer in a script ( not local script ) like theres a model in lighting called "Zakusa's buildings" or anyones name and i want it so when you leave it removes zakusa's buildings ( or anyones name ) from lighting |
|
|
| Report Abuse |
|
|
uglypoe
|
  |
| Joined: 26 Mar 2011 |
| Total Posts: 4382 |
|
|
| 17 Sep 2015 08:36 PM |
game.Players.PlayerRemoving:connect(function(plr) game.Lighting:FindFirstChild(plr.Name.."'s buildings"):remove() end) |
|
|
| Report Abuse |
|
|
Zakusa
|
  |
| Joined: 16 Feb 2013 |
| Total Posts: 359 |
|
|
| 17 Sep 2015 08:48 PM |
ya ok so i put the script in workspace and it didnt work i edited it a bit and its still not working but found a mistake
your script: game.Players.PlayerRemoving:connect(function(plr) game.Lighting:FindFirstChild(plr.Name.."'s buildings"):remove() end)
before plr.name there should be "".. i think and ya it looks correct to me i dont know why its not working |
|
|
| Report Abuse |
|
|
|
| 17 Sep 2015 08:49 PM |
Pro tip, dont listen to uglypoe, hes an actual idiot and still used the deprecated :remove(). Throw his advice out the window
(This is my signature): Im extremely sarcastic, but most of the time I will provide useful info for you! :) |
|
|
| Report Abuse |
|
|
Zakusa
|
  |
| Joined: 16 Feb 2013 |
| Total Posts: 359 |
|
|
| 17 Sep 2015 08:51 PM |
| what but i always use :remove() then removing something |
|
|
| Report Abuse |
|
|
|
| 17 Sep 2015 08:52 PM |
:remove() is deprecated(isnt practical anymore)
use :Destroy()
(This is my signature): Im extremely sarcastic, but most of the time I will provide useful info for you! :) |
|
|
| Report Abuse |
|
|
|
| 17 Sep 2015 08:54 PM |
You should never use :remove or :Remove when removing something.
:Destroy locks an instance's parent to nil and disconnects all events, freeing any memory in use by the computer associated with those events.
Instance.Parent = nil is the same thing as Instance:Remove, and should be used when you want to get an Instance back after it has been removed. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 17 Sep 2015 08:55 PM |
| Sort of, you can't necessarily get the instance back |
|
|
| Report Abuse |
|
|
Zakusa
|
  |
| Joined: 16 Feb 2013 |
| Total Posts: 359 |
|
|
| 17 Sep 2015 08:56 PM |
ya i tried this
game.Players.PlayerRemoving:connect(function(plr) game.Lighting:FindFirstChild(""..plr.Name.."'s buildings"):Destroy() end)
but it didnt work |
|
|
| Report Abuse |
|
|
| |
|