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

PointLight is not a valid member of Part?

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

lightPart = game.Workspace.LightPart
minutesAfterMidnight = 0
while true do
	minutesAfterMidnight = minutesAfterMidnight + 10
	game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight)
 	wait(.1)

 	if game.Lighting:GetMinutesAfterMidnight() == 18 * 60 then
		lightPart.Material = Enum.Material.Neon
		lightPart.Pointlight.Enabled = true
	end
	if game.Lighting:GetMinutesAfterMidnight() == 6 * 60 then
		lightPart.Material = Enum.Material.Plastic
		lightPart.PointLight.Enabled = false
	end
end

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 comment

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.

2 answers

✓ Accepted answer

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

3 comments

1

That is the error, but I proposed a way to make the script slightly better :P

0

Yes, but my goal was to fix the error in the first place, so, yay? xD

0

Man, capitalization gets me every time. Thanks!

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

lightPart = game.Workspace:WaitForChild('LightPart') -- Used a better method, than just 'workspace.LightPart' which is 'WaitForChild' which waits until the object is found
Light = lightPart:WaitForChild('PointLight') -- Used to wait until PointLight is found
minutesAfterMidnight = 0
while true do
    minutesAfterMidnight = minutesAfterMidnight + 10
    game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight)
    wait(.1)

    if game.Lighting:GetMinutesAfterMidnight() == 18 * 60 then
        lightPart.Material = Enum.Material.Neon
      Light.Enabled = true
    end
    if game.Lighting:GetMinutesAfterMidnight() == 6 * 60 then
        lightPart.Material = Enum.Material.Plastic
        Light.Enabled = false
    end
end

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