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

A function in another one?

Is possible for a function to activate when another one is fired? if yes how? for example, I want that while mouse.Button1Down is true , mouse.Idle to get activated.

1 answer

✓ Accepted answer

You can't manually activate events, but you can manually activate functions.

For example, let's say you had two functions, one for Button1Down and one for Idle:

function onButton1Down()
	--Code
end

function onIdle()
	--Code
end

If you wanted to run the Idle function while mouse.Button1Down is true, you'd have to call the Idle function from the Button1Down function, like so:

function onButton1Down()
	Idle() --This calls the Idle function
end

function Idle()
	--Code
end

Now you need to connect the functions to the events, like so:

function onButton1Down()
	Idle()
end

function Idle()
	--Code
end

Mouse.Button1Down:connect(onButton1Down) --This calls the onButton1Down function whenever the MouseButton1Down is true
Mouse.Idle:connect(Idle) --This calls the Idle function whenever the mouse is idleing

Hope this helped!

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