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

I'm trying to get the property of an item inside part inside a model, Please help?

Asked by 4 years ago
Edited 4 years ago

I have no idea how to do this, I've attempting this to work through a GUI & be able to be triggered from a model if need be. Basically, lets use ArenaLights as the main model.

Lighting = game.Lighting
ReplicatedStorage = game.ReplicatedStorage
parts = game.Workspace.ArenaLights:GetChildren() 
--------------------------------
game.ReplicatedStorage.LightingEvents.ArenaLightsEvent.OnServerEvent:Connect(function(player,arenalight)
    if arenalight == "BrightWhite" then --White Lighting
        parts.PointLight.Color = Color3.new(255/255,255/255,255/255)
        wait(0.01)
    elseif arenalight == "White" then
        parts.PointLight.Color = Color3.new(255/255,255/255,255/255)
        wait(0.01)
    elseif arenalight == "Blackout" then
        parts.PointLight.Color = Color3.new(0/255,0/255,0/255)
        wait(0.01)
    end
end)

Thank you in advance for any help you may give and any time you spend on this!

0
What are you trying to do?? Nowaha 459 — 4y
0
Alright so, i'm attemtping to get PointLight from Multiple parts inside a model to change color. Just2Terrify 566 — 4y

2 answers

Log in to vote
0
Answered by
sasial 26
4 years ago

Try This:

Lighting = game:GetService('Lighting') -- This line isn't needed though.
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.new(255/255,255/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.new(255/255,255/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.new(0/255,0/255,0/255)
            wait(0.01)
        end
        wait(0.01)
    end
end)
0
First time using the site. (: sasial 26 — 4y
0
Please provide explanations with your post. If OP does not understand this, look at my answer. I explained it :) Nowaha 459 — 4y
0
After re-looking at this as a better scripter; please add a local before everyone variable. sasial 26 — 4y
Ad
Log in to vote
1
Answered by
Nowaha 459 Moderation Voter
4 years ago
Edited 4 years ago

If I understood correctly you want to change all the PointLights inside of all the Parts inside of ArenaLights.

The simplest loop is just using a i, v pairs loop. This will loop through a list of items, in this case a list of all the children in the ArenaLights object, and give you the index (number) of the child and the child itself.

for index, child in pairs(game.Workspace.ArenaLights:GetChildren()) do
    -- Code in here will run for every single child independently.
    -- Example:
    child.PointLight.Color = Color3.fromRGB(255, 255, 255)
end

The correct usage is using i,v instead of index, child. I fixed your code for you, but it'd be good practice to try to fix it yourself using the above information. I've also used Color3.fromRGB() instead of Color3.new() because it's easier to work with.


Lighting = game.Lighting ReplicatedStorage = game.ReplicatedStorage -------------------------------- 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 v.PointLight.Color = Color3.fromRGB(255, 255, 255) end wait(0.01) elseif arenalight == "White" then for i, v in pairs(children) do v.PointLight.Color = Color3.fromRGB(255, 255, 255) end wait(0.01) elseif arenalight == "Blackout" then for i, v in pairs(children) do v.PointLight.Color = Color3.fromRGB(0, 0, 0) end wait(0.01) end end)
0
Yours showed up as a nil value Just2Terrify 566 — 4y
0
Oops sorry, my mistake. I fixed it! Nowaha 459 — 4y

Answer this question