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

Help Fix (Apology for Spamming this)?

Asked by
B3blx 5
9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

Firstly, I give credit to a user who supported me with this script, LetThereBeCode

Ok so there are 2 parts, both with cancollide false and the script within these parts disabled. I want the script to randomly choose one part and to turn both cancollide to true and the script within that part to disabled = false. I apologise for my poor explaining. Perhaps there is a simpler way to also disable the script?

local children = script.Parent:GetChildren()
while wait(3.5) do
    local choosen = children[math.random(1,#children)]
    local solidity = choosen.CanCollide == false
    local prevDisable = choosen.Script.Disabled == true
    choosen.Script.Disabled = false
    choosen.CanCollide = true
    wait(3.5)
    choosen.Script.Disabled = prevDisable
    choosen.CanCollide = solidity
end

1 answer

Log in to vote
0
Answered by 9 years ago

Line 3 and 4

 local solidity = choosen.CanCollide
 local prevDisable = choosen.Script

Line 9 and 10

prevDisable.Disabled = true
solidity.CanCollide = false

Therefore,

local children = script.Parent:GetChildren()

while wait(3.5) do
    local choosen = children[math.random(1,#children)]
    local solidity = choosen.CanCollide
    local prevDisable = choosen.Script
    choosen.Script.Disabled = false
    solidity = true
    wait(3.5)
    prevDisable.Disabled = true
    solidity = false
end
Ad

Answer this question