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

model = game.Workspace.Gate:GetChildren() -- lets say that Gate is the name of your model

for i = 1,#model do
if model[i].Name = "Cylinder" then
model[i].Transparency = 1
model[i].CanCollide = false -- could be true, you choose
end
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()

local p = script.Parent.Parent:GetChildren()
for i = 1,#p do
    if p.Name == "Cylinder" then
        if p.Transparency == 0 and p.CanCollide == false then
            p.Transparency = 1
            p.CanCollide = true
        elseif p.Transparency == 1 and p.CanCollide == true then
            p.Transparency = 0
            p.CanCollide = false
        end
    end
end

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