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

Will one error that happens when a script is ran cause lag?

Asked by 4 years ago

Alright so I just asked recently on how to get my lights to change inside of a part inside of a model. I do not know why but I consistently get a error stating Pointlight is not a valid member of Script and I want to know if that will cause any lag. Here's the script if anyone can figure out where the error is coming from. I had help from Sasial. Thank you Sasial! THIS DOES WORK, I just want to remove the error if possible What the script does. It gets all the pointlights inside of a part thats inside a model named ArenaLights and changes it when the value is triggered. I consistently get the error of Pointlight is not a valid member of Script and I'm worried it will cause lag, will it and if it will, how can I fix this? I am a fairly new scripter so I apologize in advance if I don't understand what you're saying.

Lighting = game:GetService('Lighting')
ReplicatedStorage = game.ReplicatedStorage
parts = game.Workspace.ArenaLights:GetChildren() 
--------------------------------
game.ReplicatedStorage.LightingEvents.ArenaLightsEvent.OnServerEvent:Connect(function(player,arenalight)
    if arenalight == "BrightWhite" then --White Lighting
        for i,v in pairs(parts) do
            v.PointLight.Color = Color3.fromRGB(255,255,255)
            wait(0.01)
        end
        wait(0.01)
    elseif arenalight == "White" then
        for i,v in pairs(parts) do
            v.PointLight.Color = Color3.fromRGB(255,255,255)
            wait(0.01)
        end
        wait(0.01)
    elseif arenalight == "Blackout" then
        for i,v in pairs(parts) do
            v.PointLight.Color = Color3.fromRGB(0,0,0)
            wait(0.01)
        end
        wait(0.01)
    end
end)

Thank you in advance for any time taken on this question and any answers submitted!

1 answer

Log in to vote
1
Answered by
Nowaha 459 Moderation Voter
4 years ago
Edited 4 years ago

You probably have more than just the lights inside of ArenaLights. I've added a check with if statements to see if the part contains an object named PointLight (:FindFirstChild("PointLight")).

game.ReplicatedStorage.LightingEvents.ArenaLightsEvent.OnServerEvent:Connect(function(player,arenalight)
    local children = game.Workspace.ArenaLights:GetChildren()
    if arenalight == "BrightWhite" then --White Lighting
      for i, v in pairs(children) do
        if v:FindFirstChild("PointLight") ~= nil then
          v.PointLight.Color = Color3.fromRGB(255, 255, 255)
        end
      end
      wait(0.01)
    elseif arenalight == "White" then
      for i, v in pairs(children) do
        if v:FindFirstChild("PointLight") ~= nil then
          v.PointLight.Color = Color3.fromRGB(255, 255, 255)
        end
      end
      wait(0.01)
    elseif arenalight == "Blackout" then
      for i, v in pairs(children) do
        if v:FindFirstChild("PointLight") ~= nil then
          v.PointLight.Color = Color3.fromRGB(0, 0, 0)
        end
      end
      wait(0.01)
    end
end)
0
AHH YES, Thank you so much! I do have a question for you, do you have a discord? I would love to learn what you were talking about with a Index, I'm extremely new to this stuff. Just2Terrify 566 — 4y
Ad

Answer this question