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

Why does the brick doesn't change colors when it goes through a brick?

Asked by 10 years ago

I been trying to change the brick when it touches the brick, but all it does is nothing. Ex.

function Ontouched(hit)
local found = Workspace:FindFirstChild("Brick1")
if found then 
  found.BrickColor.new(37)
    end
end

or another one Ex.

function Coloring()
    if hit.BrickColor == BrickColor(21) then
    hit.BrickColor = BrickColor.new(37)
    end
end

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
10 years ago

Well what you're doing is just checking if Brick1 exists, you're not comparing if your hit parameter is Brick1. And your coloring is off on the first script, and you have no connection statements, put this in the part to touch;

script.Parent.Touched:connect(function(hit) --Anonymous function
    if hit.Name == "Brick1" then --check the name
        hit.BrickColor = BrickColor.new() --put the color you want
    end
end)

Hope I helped, have any questions feel free to ask!(:

-Goulstem

Ad

Answer this question