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

How would I change a brick color to the color of the brick it's touching?

Asked by 7 years ago

For example an explosion on a certain terrain. If I shoot a projectile and it hits a green brick the explosion pieces will be green. I'm trying to get the explosion pieces to be the same color of the brick they touched. Here's what I got:

if hit.Anchored == true and hit.CanCollide == true then 
    for i=1,5 do -- # of explosion pecies
        local eff = game.ServerStorage.effect:Clone() --Creating
        eff.Size = Vector3.new(1,1,1) --Sizing the effect
        eff.BrickColor = BrickColor.new(hit.BrickColor) --*    
        game.Debris:AddItem(eff,1) --Destroying the effect
    end
end

I deleted the junk I don't need help with like bodyvelocity and stuff.

0
What is "hit"? Is this a snippet of the entire code? Did you check the Output? Did it return an error from the script? If so, could you please provide it? ;-; TheeDeathCaster 2368 — 7y
0
Change "eff.BrickColor = BrickColor.new(hit.BrickColor)" to "eff.BrickColor = hit.BrickColor". The property BrickColor returns a BrickColor, which isn't a valid parameter in BrickColor.new(). Thus, you can simply use hit.BrickColor. Uglypoe 557 — 7y
1
Wow it was that simple, gg. Thanks for your help Uglypoe. If you make it into an answer I'll mark it as solved. SimpleFlame 255 — 7y
0
Yeah make it an answer.. answering in comments is annoying Goulstem 8144 — 7y

Answer this question