Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Help Fix (Apology for Spamming this)?

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.