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

Why can't I change a parts color?

Asked by 5 years ago

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.

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. TommyBoy618 6 — 5y
0
Thank you for your help it really helped me in developing my game, I hope you have a nice day. SolidNice 0 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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
Ad

Answer this question