Hello I have a Start button in the StarterGui and I want to change the brick color of the part. But it doesn't seem to work. So I created a IntValue in ReplicatedStorage and when the value is 1 then in serverscriptservice it changes the BrickColor. But that doesn't work. Is there a way to make this work? Please Help Thanks
✓ ANSWER ACCEPTED
How do you change the brick color when a player presses a button?
2 answers
✓ Accepted answer
local button = script.Parent.Button
local part = game.Workspace.Part
button.MouseButton1Up:Connect(function()
part.BrickColor = BrickColor.new("Really blue")
end)
Try this. I defined the button and part which can be changed if things are different for you. When it's clicked up, it fires this function.
Here's another useful thing that includes UserInputService. DISCLAIMER: I don't recommend learning UserInputService from me but give it a try.
UserInputService is a service to detect if a player presses a key on the keyboard. for example if the player presses E they will receive an item or something like that
In your case you want to change the brickcolor
local UIS = game:GetService("UserInputService")
local Part = game.workspace.Part
UIS.InputBegan:Connect(function(input, gameprocessed)
if gameprocessed then return end
if input.KeyCode == Enum.KeyCode.E then
Part.BrickColor = BrickColor.new("Really Blue")
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.
