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

How do you get multiple Point Lights from Multiple Parts?

Asked by 3 years ago

DO NOT MIND THE MESSY CODE, I AM A BEGINNER AND THIS IS MY FIRST TIME CODING A FULL GAME.

At the beginning, there is a group called Lights as you can see from the local Purchase. Inside that group, there is multiple parts called "LightPart" and multiple parts called "Part" Inside each of the "LightPart" there is a point light.

Now, this may be complex, but how do I enable and disable the point light in these groups?

local Price = 130
local timedelay = 0.5
local amount = 1
local currencyname = "Cash"
local Purchase = game.Workspace.Purchases.LumberMill.Lights:GetChildren()
Touch = false

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        if script.Parent.Transparency == 0 then
            Touch = true
        end
        if Touch == true then
            if player.leaderstats.Cash.Value >= Price then
                player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - Price
                for _,v in pairs (Purchase) do
                    v.Transparency = 0
                    v.CanCollide = true
                end
                script.Parent:Destroy()
                    while true do
                    wait(timedelay)
                        for i,v in pairs(game.Players:GetPlayers()) do
                            if v:FindFirstChild("leaderstats") then
                                v.leaderstats[currencyname].Value = v.leaderstats[currencyname].Value + amount
                        end
                    end
                end
            end
        end
    end
end)
0
What does the code do? User#30567 0 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Try:

for Index, Part in pairs(Purchase) do
    if Part:FindFirstChild("PointLight") do
        Part.PointLight.Enabled = false -- or true, depending on what you want.
    end
end

Note: The Index is a place holder. It is usually replaced with _ but I like naming things

0
Thanks!! can you explain what Index is suppost to do at line 1? KittyCommanderXD 9 — 3y
0
Index or i 3F1VE 257 — 3y
0
Index is just a placeholder User#30567 0 — 3y
Ad

Answer this question