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)

1 comment
What does the code do?