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

PointLight is not a valid member of Part?

Asked by 9 years ago

So, I'm making a light the will follow the day/night cycle. Turns on at 6 AM, turns off at 6 PM. However, whenever it reaches 6 PM, the code will stop and say the following:

22:09:47.594 - Pointlight is not a valid member of Part 22:09:47.595 - Script 'ServerScriptService.Script', Line 12 22:09:47.596 - Stack End

01lightPart = game.Workspace.LightPart
02minutesAfterMidnight = 0
03while true do
04    minutesAfterMidnight = minutesAfterMidnight + 10
05    game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight)
06    wait(.1)
07 
08    if game.Lighting:GetMinutesAfterMidnight() == 18 * 60 then
09        lightPart.Material = Enum.Material.Neon
10        lightPart.Pointlight.Enabled = true
11    end
12    if game.Lighting:GetMinutesAfterMidnight() == 6 * 60 then
13        lightPart.Material = Enum.Material.Plastic
14        lightPart.PointLight.Enabled = false
15    end
16end

It says line 12, but in this block of code, it's line 10. I don't see anywhere where this error could have occurred. Help is appreciated. Thanks.

1
I don't know why people are downvoting this question. If anything, they should be updating it since you're actually getting the time and setting it correctly. Something that can not be stressed enough is Lua is case sensitive meaning Pointlight may not exist but PointLight does. M39a9am3R 3210 — 9y

2 answers

Log in to vote
0
Answered by
Ben1925 25
9 years ago

I believe you forgot to capitalize the L in your PointLight on Line 10 :D

1
That is the error, but I proposed a way to make the script slightly better :P yoshi8080 445 — 9y
0
Yes, but my goal was to fix the error in the first place, so, yay? xD Ben1925 25 — 9y
0
Man, capitalization gets me every time. Thanks! percyjackson149 5 — 9y
Ad
Log in to vote
1
Answered by
yoshi8080 445 Moderation Voter
9 years ago

I Don't know if this solves your problem, but

01lightPart = game.Workspace:WaitForChild('LightPart') -- Used a better method, than just 'workspace.LightPart' which is 'WaitForChild' which waits until the object is found
02Light = lightPart:WaitForChild('PointLight') -- Used to wait until PointLight is found
03minutesAfterMidnight = 0
04while true do
05    minutesAfterMidnight = minutesAfterMidnight + 10
06    game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight)
07    wait(.1)
08 
09    if game.Lighting:GetMinutesAfterMidnight() == 18 * 60 then
10        lightPart.Material = Enum.Material.Neon
11      Light.Enabled = true
12    end
13    if game.Lighting:GetMinutesAfterMidnight() == 6 * 60 then
14        lightPart.Material = Enum.Material.Plastic
15        Light.Enabled = false
16    end
17end

Answer this question