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

Is firing an event from a function incorrect?

So I have a function that listening to an event, the event already has a written function inside of it:

function Normal()
	mouse.Button1Down:Connect(mouseClick)
end

My question is, I'm not sure if that is a good idea to put an event like that. If it is okay to put it like that, does it come with any down sides? If not is there an alternative?

1 comment

0

?

1 answer

✓ Accepted answer

Hello, the downside about that is it won't capture your mouse clicks unless you run that function called "normal" because of it's in a function it can't run until the function is called, the mouse capturing event will only and only listen when the "normal" function is fired and when it's done with firing the function and the function ends so will the capture event, so you shouldn't put a mouse capturing event inside a function.

2 comments

0

So I am trying to make ‘zombie classes’ for a zombie game. Different classes have the same events but are scripted differently for their class. So I don’t want like 4 listeners I want only 1 listener. Is it fine whenever I change the class I would disconnect the previous class’s event and reconnect to a new one?

0

Sure.

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