Hello,
I am currently making a hat customizer system and was wondering how exactly I could get these rgb values to change the color of a hat? So far I have this:
Local Script:
local p = game:GetService("Players").LocalPlayer
local AccessoryName = script.Parent.Parent.Parent.TextLabel.Text -- making sure its the right accessory
script.Parent.MouseButton1Click:Connect(function()
-- there are 3 text boxes serving as the rgb value changer
local r = tonumber(script.Parent.Parent.Parent.R.Text)
local b = tonumber(script.Parent.Parent.Parent.G.Text)
local g = tonumber(script.Parent.Parent.Parent.B.Text)
game:GetService("ReplicatedStorage").CustomEvents.Rgb:FireServer(p, AccessoryName, r, g, b)
end)
Server Script:
game.ReplicatedStorage.CustomEvents.Rgb.OnServerEvent:Connect(function(p, AccessoryName, r, g, b)
local children = p.Character:GetChildren()
for i, child in ipairs(children) do
if child:IsA("Accessory") then
if child.Name == AccessoryName then
child.Handle.Color = Color3.fromRGB(r, g, b)
end
end
end
end)
I tried handle.Color, handle.Mesh.Vortexcolor and nothing works, I can’t find any articles on how to achieve this. Does anybody know how I could possibly achieve this?
from what i remember you cant change the color of a basepart object that have special mesh parented to it
however there is a special basepart where it have meshid property that function exact the same like special mesh but you can change it color
Actually, you can. The SpecialMesh just has to have no texture. Besides, SpecialMeshes aren’t used in Accessories anymore, at least not by default. Older places might still be using SpecialMeshes.
If you want to change an accessory’s color, you’ll need to set the TextureID property of the corresponding MeshPart to a blank string, and then change the Color property of that MeshPart.
game.ReplicatedStorage.CustomEvents.Rgb.OnServerEvent:Connect(function(p, AccessoryName, r, g, b)
local children = p.Character:GetChildren()
for i, child in ipairs(children) do
if child:IsA("Accessory") then
if child.Name == AccessoryName then
local meshPart = child:FindFirstChildOfClass("MeshPart")
if (meshPart) then
meshPart.TextureID = ""
meshPart.Color = Color3.fromRGB(r, g, b)
end
end
end
end)
SpecialMeshes aren’t used in accessories anymore, so don’t worry about checking for them. It’s only MeshParts now, unless R6 is enabled in your place.
As I said, the first argument of RemoteEvent.OnServerEvent() is player no matter what
It’s automatically passed through whenever a client does FireServer. This more of a security thing so that someone can’t send a different player through the remote event and thus act like they’re someone else
If I did this on the client
Remote:FireServer(123, true)
On the server I’d get
Remote.OnServerEvent:Connect(function(a, b, c)
print(a, b, c) -- kingerman88, 123, true
end)