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

Module script function fires when the place starts?

I have the module script:

local module = {}

function module.StartUp(blox)
	local gui = blox.Screen.StartUp
	local rotate = gui.Frame.ImageLabel
	local y = 1 
	local on = false
	local button = blox.onoff
	
	if on == false then
		on = true
		button.Material = Enum.Material.Neon
		gui.Enabled = true
		wait(2)
		rotate.Visible = true
		y = 1
		rotate.Rotation = 0
			while y < 1000 do
				y = y + 1
				rotate.Rotation = y
				if on == false then
					break
				end
				wait(.01)
			end
	else
		button.Material = Enum.Material.SmoothPlastic
		on = false
		gui.Enabled = false
		rotate.Visible = false
	end
end

return module

The startup function is supposed to trigger when the button that parents the following script is clicked:

local click = script.Parent.ClickDetector
module = require(script.Parent.Parent.functions)

click.MouseClick:connect(module.StartUp(script.Parent.Parent))

But it just runs when the game starts, why and what can I do about that?

1 answer

✓ Accepted answer

Hi radusavin366,

In your MouseClick connection, try to connect the event to a function rather than just calling on the function in there. Do something like this:

click.MouseClick:Connect(function()
	module.StartUp(script.Parent.Parent);
end)

##Well, I hope I helped and have a nice day/night.

Thanks,

Best regards,

~~ KingLoneCat

4 comments

0

Thank you :)

1

Ewww who uses ;

0

Maybe he's used to C++ or another language that requires a ";" after a function is called.

0

Literally, most languages use ; and I used Java before so, I want to make it a habit to use it.

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