Firstly, I give credit to a user who gave me the 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 to turn both cancollide to true and the script within that part to disabled = false. I apologise for my poor explaining.
01 | local children = script.Parent:GetChildren() |
02 | while wait( 3.5 ) do -- put 'time' to how many seconds it takes to choose the next part |
03 | local choosen = children [ math.random( 1 ,#children) ] |
04 | local solidity = choosen.CanCollide = false |
05 | local prevDisable = choosen.Script.Disabled = true |
06 | choosen.Script.Disabled = false |
07 | choosen.CanCollide = true |
08 | wait( 3.5 ) -- put 'time' to how many seconds it takes for part to return to the previous color |
09 | choosen.Transparency = prevDisable |
10 | choosen.CanCollide = solidity |
11 | end |
On lines 4 and 5, local solidity = choosen.CanCollide = false
and local prevDisable = choosen.Script.Disabled = true
should read local solidity = choosen.CanCollide == false
and local prevDisable = choosen.Script.Disabled == true
On line 9, Transparency is a number. prevDisable is not a number.
01 | local children = script.Parent:GetChildren() |
02 | while wait( 3.5 ) do -- put 'time' to how many seconds it takes to choose the next part |
03 | local chosen = children [ math.random(#children) ] |
04 | local solidity = not chosen.CanCollide |
05 | local prevDisable = chosen.Script.Disabled |
06 | chosen.Script.Disabled = false |
07 | chosen.CanCollide = true |
08 | wait( 3.5 ) -- put 'time' to how many seconds it takes for part to return to the previous color |
09 | chosen.Transparency = prevDisable and 1 or 0 |
10 | chosen.CanCollide = solidity |
11 | end |