Functions inside other functions?

local leaderstats = Instance.new("Folder", plr)
	leaderstats.Name = "leaderstats"
	
	local cashv = Instance.new("IntValue", leaderstats)
	cashv.Name = "Cash"
	
	cashv.Value = plrData.Cash
	
	cashv.Changed:Connect(function()
		plrData.Cash = cashv.Value
	end)

Would the cashv.Changed function prevent anything further in the script from running correctly?

No? Why would it?

Just making sure.

A way to answer this without needing to ask is to check on DevHub to see if it says it yields.

Stuff like loops, waits (obviously) and a few other things will yield scripts unless wrapped in coroutines/spawn (spawn isn’t the best idea, use coroutines if you must)

Events will never yield or interrupt the current thread.

1 Like