How to make it so that the player can chose any RGB color for a tool?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want it to make it so the player can choose any RGB color for the tool.

  2. What is the issue? Include screenshots / videos if possible!
    The color won’t change for some reason.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have, and I tried looking for videos but it didn’t work.

Local Script

local Event = game.ReplicatedStorage:WaitForChild('ColorChange')\

script.Parent.MouseButton1Click:Connect(function()
	Event:FireServer()
end)

Server Script

local Event = game.ReplicatedStorage:WaitForChild("ColorChange")
local player = game:GetService("Players").PlayerAdded:Wait()
local frame = player.PlayerGui:WaitForChild("ScreenGui").Frame

Event.OnServerEvent:Connect(function()
	player.Character.Tool.Handle.Color = Color3.fromRGB(frame.RBOX.Text, frame.GBOX.Text,frame.BBOX.Text)		
end)
1 Like

Just so you know, the tool turns block upon putting the color.

Are there any errors in pathing a variable or something else? Also I suggest using tonumber() in case someone put like “w” for R instead of a number tonumber(frame.RBOX.Text)

also is “frame” supposed to be capitalized?

You have to pass R, G, and B values through the remote event as the PlayerGui doesn’t replicate. You should also restrict entering letters or numbers above 255 to prevent breaking.

I’m still new to scripting, how do I do that?

“frame” is the local variable. Also, there were no errors in the console about the variables.

1 Like

Put the frame text inside of the fire server, then you can get it through the other end. Example: FireServer(frame.RBOX.Text, frame.GBOX.Text,frame.BBOX.Text) then OnServerEvent(R,G,B) make sure to add local variables for the frame son the client.

1 Like

Local scripts fire with
:FireServer()
and receive with
:OnClientEvent()

Server scripts fire with :FireAllClients()/:FireClient()
and receive with
:OnServerEvent
If that’s what you mean?

1 Like

Did you try changing these to tonumber()
image

tonumber(frame.RBOX.Text)

Also for the local script, there is a random “/“ on line 1.
So for the first script, use a localscript inside a textbutton

For the second script, use a server script in serverscriptservice

1 Like

You would actually use a client script in starter player scripts.

Changed those, still didn’t work.

You can use :MouseButton1Click() in SPS? Didn’t know that.

Is this good?

Event.OnServerEvent:Connect(function(R, G, B)

I don’t know if :OnServerEvent() can receive from local scripts.

Hold on be right back, gotta do dishes.

Yea it is good, but this is the server part. Make sure you also add the client part.

Just did, so next do i add a local variables for each of those letters inside?

No, they are the values already. Add variables for the frames in the client script.

Event:FireServer(script.Parent.Parent.RBOX.Text, script.Parent.Parent.GBOX.Text, script.Parent.Parent.BBOX.Text)

Yep! This will work, now I think you are done. Just so this if you haven’t already:


player.Character.Tool.Handle.Color = Color3.fromRGB(R,G,B)	

1 Like