Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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())
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. andrewplayer 0 — 6y

1 answer

Log in to vote
0
Answered by
CootKitty 311 Moderation Voter
6 years ago
Edited 6 years ago

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.
Ad

Answer this question