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

How to gather parts and change properties all at once??

Asked by 9 years ago

I forgot. Halp. Please. For the love of almighty Jesus.

To be more specific, I have a gate that needs all the objects within named "Cylinder" to become transparent and non-colliding.

0
A note, you can't technically do two things at "once." Perhaps if you have a quantum computer. ;) Programmix 285 — 9y
0
But even then , quantum computers will never be able to process as much data as a game needs to for the next millennium or two. konichiwah1337 233 — 9y

2 answers

Log in to vote
2
Answered by
Codebot 85
9 years ago

Next time provide proof that you even tried to make the script

1model = game.Workspace.Gate:GetChildren() -- lets say that Gate is the name of your model
2 
3for i = 1,#model do
4if model[i].Name = "Cylinder" then
5model[i].Transparency = 1
6model[i].CanCollide = false -- could be true, you choose
7end
Ad
Log in to vote
0
Answered by 9 years ago

@1st answer Sorry, I was desperate, it was 4AM, and I was being a little lazy xD Here was the original script

script.Parent.Lever.ClickDetector.MouseClick:connect(function()

01local p = script.Parent.Parent:GetChildren()
02for i = 1,#p do
03    if p.Name == "Cylinder" then
04        if p.Transparency == 0 and p.CanCollide == false then
05            p.Transparency = 1
06            p.CanCollide = true
07        elseif p.Transparency == 1 and p.CanCollide == true then
08            p.Transparency = 0
09            p.CanCollide = false
10        end
11    end
12end

end)

EDIT: Anyone curious out there, I finalized the script. Thanks @First Answer

local ooc = script.Parent.OpenOrClosed --checks if the gate is open/closed --false = closed, true = open, its a boolean value.

script.Parent.Lever.ClickDetector.MouseClick:connect(function() local model = game.Workspace.Gate:GetChildren() for i = 1,#model do if model[i].Name == "Cylinder" and ooc == false then model[i].Transparency = 1 model[i].CanCollide = false ooc = true else model[i].Transparency = 0 model[i].CanCollide = true ooc = false end end end)

Answer this question