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

What went wrong?

Asked by 9 years ago

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

I am new at scripting to so I decided I would try to make a code where when you touch part, it's collide is false for 3 seconds then returns to normal. Also when the brick is in "Can't collide" the color of part2 changes as well. So can anyone point out the error?

Base = Script.Parent.Parent.Part
Colors = game.Workspace.Part2

function onTouched (hit)
    Base.Transparency = 1
    Base.CanCollide = false
    wait(3)
    Base.Transparency = 0.3
    Base.CanCollide = true
end

Script.Parent.Touched:connect(onTouched)

if Base.CanCollide = false then
    Colors.BrickColor = Brightgreen
end

if Base.CanCollide = true then
    Colors.BrickColor = Brightred
end

3 answers

Log in to vote
0
Answered by
IcyEvil 260 Moderation Voter
9 years ago

USerOnly16Characters Was Right Half way as well, He made a simple spelling error, That I will fix for him.

Base = Script.Parent.Parent.Part
Colors = game.Workspace.Part2

function onTouched (hit)
    Base.Transparency = 1
    Base.CanCollide = false
    wait(3)
    Base.Transparency = 0.3
    Base.CanCollide = true
end

Script.Parent.Touched:connect(onTouched)

if Base.CanCollide == false then--When your checking something you must have two equals
    Colors.BrickColor = BrickColor.new("Bright green")--Had 'Brighten green'
end

if Base.CanCollide == true then--When your checking something you must have two equals
    Colors.BrickColor = BrickColor.new("Bright red")
end
Ad
Log in to vote
9
Answered by 9 years ago

In line 15 and 19 you made a very simple mistake.

Base = Script.Parent.Parent.Part
Colors = game.Workspace.Part2

function onTouched (hit)
    Base.Transparency = 1
    Base.CanCollide = false
    wait(3)
    Base.Transparency = 0.3
    Base.CanCollide = true
end

Script.Parent.Touched:connect(onTouched)

if Base.CanCollide == false then--When your checking something you must have two equals
    Colors.BrickColor = BrickColor.new("Bright green")
end

if Base.CanCollide == true then--When your checking something you must have two equals
    Colors.BrickColor = BrickColor.new("Bright red")
end
0
If I solved your problem I would appreciate if you could accept my answer. UserOnly20Characters 890 — 9y
Log in to vote
0
Answered by
exit16 20
9 years ago

You can easily make your brick CanCollide turn false with a WAY easier script.~~~~~~~~~~~~~~~~~ local brick = workspace.Brick function onTouched(hit) brick.CanCollide = false wait(3) brick.CanCollide = true end brick.Touched:connect(onTouched) ~~~~~~~~~~~~~~~~~

Answer this question