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

Is there a way to connect an event to a function?

Is there a way to include an event, such as .Changed and connect it to a function. This is what I have so far, why doesn't it work?

local function Light()
	while script.Parent.Parent.Parent.Danger.Value==true do
		for i=0,180,1 do
			script.Parent.Orientation = Vector3.new(0,i,0)
			wait(0.01)
		end
	end
end

script.Parent.Parent.Parent.Danger.Changed:connect(Light())

1 comment

0

you put "(Light())". You're soppose to call the function by putting its name. You dont have to put the () after light or it wont work.

1 answer

✓ Accepted answer

Super close. You don't don't put the extra ().

script.Parent.Parent.Parent.Danger.Changed:Connect(Light)
This also means you can't pass arguments to the function without either an anonymous functions.

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