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

Why can't I change a parts color?

So I tried to change a parts color using a screen gui script. So I basically try to use a textbutton to change a parts color for a rpg game. This is my script(its a local script)

local button = script.Parent
local platform = game.Workspace.Spawn.Platform


button.MouseButton1Click:Connect(function()
	if platform.BrickColor ~= platform.BrickColor("Toothpaste") then
		platform.BrickColor = BrickColor.new("Toothpaste")
	end
end)

Please help me and tell me whats wrong.

2 comments

1

I believe you simply need to remove 'platform.BrickColor' after the not equals and put 'if platform.BrickColor ~= ("Toothpaste")'. I've tested this with a Touched event and it seems to work.

0

Thank you for your help it really helped me in developing my game, I hope you have a nice day.

1 answer

You simply have to remove the ‘platform.BrickColor’ function after the “if platform.BrickColor ~=“ function, so for example.

local button = script.Parent
local platform = game.Workspace.Spawn.Platform


button.MouseButton1Click:Connect(function()
    if platform.BrickColor ~= ("Toothpaste") then
        platform.BrickColor = BrickColor.new("Toothpaste")
    end
end

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