Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Can you make custom function like things?

Basically what I am asking is if you can make custom 'functions' in a script and then later call them. I think it is possible but if so I don't have much of an idea of how to do so. Here is how I think it would work.

local function1=function()
	for i,v in pairs(game.Players:GetChildren()) do
		v.Character.Torso:Destroy()
	end
end

Any help?

2 comments

0

Just a tip, functions are already local variables (as they cannot be called outside the scope that they are declared in.) You can store a function as a global by putting "_G." before the name.

0

That is not true. A local variable and a global variable have nothing to do with _G.

1 answer

✓ Accepted answer

A function is something you call when you need the it to run.

Ex.

function Run(Player) 
	print(Player.Name .. " has entered the server");
end

game.Players.PlayerAdded:connect(function(Player)
	Run(Player) 
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.