Is it possible to know when a Funcion has "Finished"

For example:


What i want to know is if the script can detect and run another function when “CreateTheHolThin()” has ended

I don’t think Roblox has a built in command to tell when it ends, but you could try this simple idea. Make a variable, and put the value as false. In your CreateTheHolThin() function, after CreatePart(), set the value to true. Since that’s around the end of the function, it’s kind of a way to detect when the function has ended. Sort of like this:

local functionended = false

local function CreateTheHolThin()
	local startX = GrassPlate.Position.X - GrassPlate.Size.X / 2 + 0.5
	local startZ = GrassPlate.Position.Z - GrassPlate.Size.Z / 2 + 0.5
	local endX = GrassPlate.Position.X + GrassPlate.Size.X / 2 - 0.5
	local endZ = GrassPlate.Position.Z + GrassPlate.Size.Z / 2 - 0.5
	
	for x = startX, endX do
		for z = startZ, endZ do
			CreatePart(x, z, GrassPlate)
			functionended = true
		end
	end
end

#help-and-feedback:scripting-support is where you should direct this sort of question, for any future posts you make like this.


Roblox functions are by default going to yield until they are finished, so if you want to run a second function when CreateTheHolThin(), then just add it on the line afterwards.

e.g.

local function CreateTheHolThin()
    ... -- replace dots with the actual contents of the functions obv. These are just 
end

local function SecondFunction()
    ... -- replace dots with the actual contents of the functions obv.
end

CreateTheHolThin()
SecondFunction()
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.