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

Can Anyone Help Fix This Script?

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.

local children = script.Parent:GetChildren()
while wait(3.5) do -- put 'time' to how many seconds it takes to choose the next part
    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) -- put 'time' to how many seconds it takes for part to return to the previous color
	choosen.Transparency = prevDisable
	choosen.CanCollide = solidity
end

1 comment

0

Read the output. You didn't even post the syntax errors this has.

1 answer

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.

local children = script.Parent:GetChildren()
while wait(3.5) do -- put 'time' to how many seconds it takes to choose the next part
    local chosen = children[math.random(#children)]
    local solidity = not chosen.CanCollide
    local prevDisable = chosen.Script.Disabled
    chosen.Script.Disabled = false
    chosen.CanCollide = true 
    wait(3.5) -- put 'time' to how many seconds it takes for part to return to the previous color
    chosen.Transparency = prevDisable and 1 or 0
    chosen.CanCollide = solidity
end

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