Feedback On My First Script

Hello, I have recently been learning the fundamentals of Lua. With the basic knowledge I know I decided to make a type of flying script with“Part”), any feedback would be greatly appreciated!


This is really good for your first script!

One tip though. Instead of using block:Destroy(), you should use Debris.

	local block = Block()
	block.Position = player.Character.RightFoot.Position
	game.Debris:AddItem(block, 2) -- this will wait 2 seconds (not yielding the code) and then destroy the block

Debris is bassically the same as Destroy, except:

  • It doesnt pause the script like wait() does
  • It doesnt error if the object your destroying doesnt exist
  • You can add a delay time

The first argument is the item you want to destroy, and the second argument is the time you want to wait before it gets destroyed. By default though, the delay is set to 10 seconds if you leave it blank. So if you want it to be destroyed instantly, make sure you still add in 0 or 0.1

1 Like

Hey thank you for the insight, I will be definitely implementing this into my code!

1 Like