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 » Scripters
Home Search
 

Re: Script of the day 01:

Previous Thread :: Next Thread 
TaskScheduler is not online. TaskScheduler
Joined: 14 May 2013
Total Posts: 497
14 Oct 2015 09:47 PM
Hey guys I thought it'd be cool to make a new series I call script of the day, basically some days I post a script and give you a few days to understand it before I post another but it might have days in a row if they're simple brick scripts or something.


Anyway here it is:
game.Workspace.Player.Head:Remove()

A classic this script removes players head, change the name to use in your game. Depending on the responses I may wait a few days or not, comment below if you get it and request for scripts!
Report Abuse
Lineout is not online. Lineout
Joined: 06 Nov 2012
Total Posts: 684
14 Oct 2015 09:48 PM
I have a feeling the form leaders are going to destroy you for this.



Eyyyo
Report Abuse
lostend is not online. lostend
Joined: 21 Aug 2011
Total Posts: 8265
14 Oct 2015 09:50 PM
my understanding of it:

a useless script that can error if player doesn't exist and uses a deprecated method to parent it to nil
Report Abuse
Lineout is not online. Lineout
Joined: 06 Nov 2012
Total Posts: 684
14 Oct 2015 09:50 PM
^



Eyyyo
Report Abuse
TaskScheduler is not online. TaskScheduler
Joined: 14 May 2013
Total Posts: 497
14 Oct 2015 09:51 PM
lostend: Good point! That's called a static reference, which means you have to make sure Player exists.
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
14 Oct 2015 09:52 PM
bruh

workspace.Player1.Head:Destroy()

please use Destroy lol. And no need for game.Workspace, you can just use workspace.

-The [Guy]
Report Abuse
TaskScheduler is not online. TaskScheduler
Joined: 14 May 2013
Total Posts: 497
14 Oct 2015 09:53 PM
Both of your "corrections" are changes, but I will consider using those in the future!
Report Abuse
TaskScheduler is not online. TaskScheduler
Joined: 14 May 2013
Total Posts: 497
14 Oct 2015 09:54 PM
Opinions* my bad.
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
14 Oct 2015 09:55 PM
:Destroy() > :Remove(), because the latter is deprecated.

-The [Guy]
Report Abuse
Lineout is not online. Lineout
Joined: 06 Nov 2012
Total Posts: 684
14 Oct 2015 09:55 PM
Remove() being deprecated is not an opinion.



Eyyyo
Report Abuse
TaskScheduler is not online. TaskScheduler
Joined: 14 May 2013
Total Posts: 497
14 Oct 2015 09:58 PM
"Deprecation is an attribute applied to a computer software feature, characteristic, or practice to indicate that it should be avoided"

It's recommended but in some cases like this it's better.
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
14 Oct 2015 09:59 PM
Better? Curious, how so? Being deprecated means you shouldn't rely on it because it may or may not exist in the future and if it doesn't, will break your scripts. It also usually means there is a newer alternative method that is superior in some way.

-The [Guy]
Report Abuse
RecurringNightmare is not online. RecurringNightmare
Joined: 05 Jul 2012
Total Posts: 15336
14 Oct 2015 10:01 PM
o.e
Report Abuse
TaskScheduler is not online. TaskScheduler
Joined: 14 May 2013
Total Posts: 497
14 Oct 2015 10:01 PM
It was made first its faster, if you need that additional functionality you use destroy.
Report Abuse
ShadowOfCrimson is not online. ShadowOfCrimson
Joined: 14 Dec 2009
Total Posts: 2153
14 Oct 2015 10:02 PM
I'm curious... If we used :Destroy() on 1000 objects, and used :Remove() on 1000 objects, which one would be faster or more efficient?
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
14 Oct 2015 10:04 PM
Remove() exists for compatibility and should not be used in new scripts. It shouldn't.

:Destroy will disable it from being re-parented after being set to nil and it disconnects all functions that are acting on it. It calls the same function for all of its children. This "Additional functionality" is rather important.

-The [Guy]
Report Abuse
ShadowOfCrimson is not online. ShadowOfCrimson
Joined: 14 Dec 2009
Total Posts: 2153
14 Oct 2015 10:05 PM
I'm not interested in that aspect of the situation, I said which is more efficient?
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
14 Oct 2015 10:11 PM
I don't know. Run a test and find out. Take the tick() at the end minus the tick() at the start for both functions. Compare the differences.

-The [Guy]
Report Abuse
chimmmihc is not online. chimmmihc
Joined: 24 Jul 2014
Total Posts: 2420
14 Oct 2015 10:26 PM
Why not this? It's not the best thing in the world but it looks like your going for one liners.

local FoundCharacter = Player and Player.Character and Player.Character:FindFirstChild("Head")
if FoundCharacter then Player.Character.Head:Destroy() else return end

Would that not be better? Is the point of this series fame or to teach because as of right now you might as well as thought of a name pasted a line of code and begged for attention. Either way you got the attention.
Report Abuse
ShadowOfCrimson is not online. ShadowOfCrimson
Joined: 14 Dec 2009
Total Posts: 2153
14 Oct 2015 10:26 PM
They both vary from .1365s to .1428s
The difference is negligible on average and neither has any sort of advantage for time.
Report Abuse
chimmmihc is not online. chimmmihc
Joined: 24 Jul 2014
Total Posts: 2420
14 Oct 2015 10:29 PM
Speed is not the problem with using remove(), the problem is remove doesn't completely delete the instance from the data model. However destroy disconnects the instance completely. I believe :)
Report Abuse
ShadowOfCrimson is not online. ShadowOfCrimson
Joined: 14 Dec 2009
Total Posts: 2153
14 Oct 2015 10:34 PM
I tried using both with 1000 pieces... I don't think it matters.
Report Abuse
chimmmihc is not online. chimmmihc
Joined: 24 Jul 2014
Total Posts: 2420
14 Oct 2015 10:42 PM
It does because when you remove instances they're still technically there, which can potentially use resource time.
Report Abuse
CLIMAXIMUS is not online. CLIMAXIMUS
Joined: 22 Jun 2012
Total Posts: 1738
14 Oct 2015 10:42 PM
task is this a joke
Report Abuse
cody123454321 is not online. cody123454321
Joined: 21 Nov 2009
Total Posts: 5408
15 Oct 2015 12:53 AM
getfenv()["remove"] = function(obj)
game.Destroy(obj)
end

remove(game.Workspace.Player.Head)

Save a whopping 1 char. Only really useful when you call remove 54 different times in your script.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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