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

Can Anyone Help Fix This Script?

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 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

0
Read the output. You didn't even post the syntax errors this has. 1waffle1 2908 — 9y

1 answer

Log in to vote
0
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
9 years ago

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
Ad

Answer this question