Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
1

How do you get multiple Point Lights from Multiple Parts?

Asked by 7 days 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? TTChaos 200 — 7d

1 answer

Log in to vote
0
Answered by
TTChaos 200 Moderation Voter
7 days ago
Edited 6 days 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 — 6d
0
Index or i dimondflash57 44 — 6d
0
Index is just a placeholder TTChaos 200 — 6d
Ad

Answer this question