So today I was trying to make a script where there are white parts (DayBrick) and black parts (NightBrick). I wanted to make a script where on a ScreenGui button click any of the bricks disappear (NOTE: There are mutliple parts named 'NightBrick' and 'DayBrick'). The script is set as a Script and put into Workspace. The goal is that the script must detect all of the parts named each of them and change what they do/are.
Day = game.StarterGui.ScreenGui.DayButton
Night = game.StarterGui.ScreenGui.NightButton
DayBrick = game.Workspace.DayBrick
NightBrick = game.Workspace.NightBrick
Day.MouseButton1Click:connect(function()
for _,Part in next, (game.Workspace:GetChildren()) do
if (Part .Name == "DayBrick") and Part :IsA("BasePart") then
DayBrick.Transparency = 0
DayBrick.CanCollide = true
NightBrick.Transparency = 1
NightBrick.CanCollide = false
end
end
end)
Night.MouseButton1Click:connect(function()
for _,Part in next, (game.Workspace:GetChildren()) do
if (Part .Name == "NightBrick") and Part :IsA("BasePart") then
DayBrick.Transparency = 1
DayBrick.CanCollide = false
NightBrick.Transparency = 0
NightBrick.CanCollide = true
end
end
end)

1 comment
Use game.Selection:Set()