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

How do you change a parts color if you touch another part?

When you touch the scripts parent, a object in the workspace should change color and then unanchor and create an explosion. It cant get to the explosion because it won't change color. How do I make it change color?

script.Parent.Touched:Connect(function()
	script.Parent.Parent.Parent.Parent.ff.BrickColor(255,0,0)
	wait(3)
	script.Parent.Parent.Parent.Parent.ff.Anchored = false
	local explosion = Instance.new("Explosion")
	explosion.Position = script.Parent.Parent.Parent.Parent.ff.Position
	explosion.Parent = game.Workspace
end)

1 answer

You aren't using BrickColor correctly. You should be using BrickColor.new, but in this case you want RGB. You should use Color3.fromRGB instead.

Code example:

script.Parent.Touched:Connect(function()
    script.Parent.Parent.Parent.Parent.ff.Color = Color3.fromRGB(255,0,0)
    wait(3)
    script.Parent.Parent.Parent.Parent.ff.Anchored = false
    local explosion = Instance.new("Explosion")
    explosion.Position = script.Parent.Parent.Parent.Parent.ff.Position
    explosion.Parent = game.Workspace
end)

This code has not been tested prior to response there may be other issues covered by other answers.

Hope this helps!

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