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

What is wrong with my script?

Asked by 10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

I tried to make a sphere bulb that turns on and off. The sphere was put under workspace and i inserted a script and a PointLight into it...... Here is the code I had trouble with it says line 6 is the problem...

 lightupsphere = script.Parent
--print(lightupsphere)--was used as test
while true do 
    for i,v in pairs(lightupsphere:getChildren()) do
        if(v~=script) then
        v.Sphere.PointLight.Enabled = not v.Sphere.PointLight.Enabled    
        end
    end
    wait(2)
end

3 answers

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

Assuming lightupsphere is the sphere with the light in it:

v in line 4 is a child of lightupsphere. That would make it either the script or the PointLight.

You don't need v.Sphere.PointLight -- the PointLight is v.

v.Enabled = not v.Enabled


(While this is not wrong in your script) It would be a better check, rather than v ~= script to actually require that v is a light:

if v:IsA("Light") then
-- Light is a super-class for PointLight and SpotLight
Ad
Log in to vote
2
Answered by 10 years ago

@Andrew ... Your script doesnt even work lol the other guys fix is all that was needed read his did you even test it lol

Log in to vote
0
Answered by 10 years ago
lightupsphere = script.Parent
\
--print(lightupsphere)--was used as test

while true do

    for i,v in pairs(lightupsphere:getChildren()) do

        if v:IsA("Light") then

        v.Sphere.PointLight.Enabled = v.Sphere.PointLight.Disabled  

        end

    end

    wait(2)

end

Answer this question