I'm totally new to scripting and I have no idea what to do about this. I only build stuff rather than scripting. So I made a tool and when it is equipped a gui pops up in which you can change the color of the tool's handle. But the script I'm looking for is how can I use the gui's button to change the color of the tool's handle? (Basically, I need the script for it.)
How can I make a gui change a part's color when it's clicked?
2 answers
ok so there is a things RemoteEvents
a Remote Event is something that fires to the server so that the server can see it... it uses two scripts
-a local script to send whatever request to the other script or server -and a script to recive the request and grant it to the server so everyone can see
so you want to press a button on Gui to change the brick color of a brick
first go to the "Insert object" a pick the "Remote Event" then put that remote Event in Replicated Storage and Call it whatever you want
now put a LocalScript in your button and lets's begin scripting :)
local button = script.Parent--Your button
local Remote = game.ReplicatedStorage.EVENT_NAME_HERE--the name you named your remote event
button.MouseButton1Click:Connect(function()--something happens when clicked
Remote:FireServer()--now we fired this Event now time to move On! :)
end)
now put a Script into your workspace and type this
local Remote = game.ReplicatedStorage.EVENT_NAME_HERE--the name you named your remote event
local color = "put your color in between these Qotation Marks"
Remote.OnServerEvent:Connect(function(player)--Anything below will happen when you remote has been fired!
game.Workspace.Your_Part_Here.BrickColor = BrickColor.new(color)--the brick shall turn into the color you want
end)
and there you go!
if you had any problems with this script leave a comment below!
keep scripting and don't give up! Good Luck and Have a good day! :D
--T40
put a remoteevent in replicated storage and name it handlecolor
--LocalScript in the button
script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.handlecolor:FireServer()
end)
ergergergerge
--Script in ServerScriptService
--Rename Sword to the weapon that's equipped don't remove the quotes
local tool = "Sword"
game.ReplicatedStorage.handlecolor.OnServerEvent:Connect(function(player)
if player.Character:FindFirstChild(tool) then
player.Character[tool].Handle.BrickColor = BrickColor.new("Really red")
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
on line 7 you can replace "game.Workspace" with "script.Parent" or anything that you need to reference the part with.If not then Leave it.