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

How can I make a gui change a part's color when it's clicked? [closed]

Asked by
bluense -10
6 years ago
Edited 6 years ago

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.)

Closed as Not Constructive by aazkao, green271, zblox164, and User#21908

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

2 answers

Log in to vote
0
Answered by
Tizzel40 243 Moderation Voter
6 years ago

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

0
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. Tizzel40 243 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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)