Recently, I’ve forked EgoMoose’s Circular Color Palette GUI and modified it to use it on a model. The model has a VehicleSeat in it.
However, I had no luck in doing this, and I attempted to solve it in two different ways.
- Spawn it via the client, however, a player cannot get into the VehicleSeat despite showing the colors, as seen here:
- Spawn it via the server using a RemoteEvent, however, only spawns the default colors of the model but the player can get into the VehicleSeat, as seen here:
The code below shows that I am attempting to spawn the kart via the server.
Code
Main Color Selector Script (LocalScript):
local dragger = require(script:WaitForChild("dragger"));
local slider = script.Parent:WaitForChild("Slider")
local slide = slider:WaitForChild("Slide")
local wheel = script.Parent:WaitForChild("Wheel");
local ring = wheel:WaitForChild("Ring");
colour = script.Parent:WaitForChild("Colour");
local kartbody = script.Parent.Parent.Parent.ViewportFrame.Kart.Body
--
local function toPolar(v)
return math.atan2(v.y, v.x), v.magnitude;
end
local function radToDeg(x)
return ((x + math.pi) / (2 * math.pi)) * 360;
end
--
local hue, saturation, value = 0, 0, 1;
local function update()
colour.BackgroundColor3 = Color3.fromHSV(hue, saturation, value);
for i, v in ipairs(kartbody:GetChildren()) do
v.Color = colour.BackgroundColor3
end
end
-- dragger
local slideDrag = dragger.new(slide);
local ringDrag = dragger.new(ring);
function slideDrag:onDrag(guiElement, input, delta)
local rY = input.Position.y - slider.AbsolutePosition.y;
local cY = math.clamp(rY, 0, slider.AbsoluteSize.y - slide.AbsoluteSize.y);
guiElement.Position = UDim2.new(0, 0, 0, cY);
value = 1 - (cY / (slider.AbsoluteSize.y - slide.AbsoluteSize.y));
guiElement.BackgroundColor3 = Color3.fromHSV(0, 0, 1-value);
update();
end
function ringDrag:onDrag(guiElement, input, delta)
local r = wheel.AbsoluteSize.x/2
local d = Vector2.new(input.Position.x, input.Position.y) - wheel.AbsolutePosition - wheel.AbsoluteSize/2;
if (d:Dot(d) > r*r) then
d = d.unit * r;
end
guiElement.Position = UDim2.new(0.5, d.x, 0.5, d.y);
local phi, len = toPolar(d * Vector2.new(1, -1));
hue, saturation = radToDeg(phi)/360, len / r;
slider.BackgroundColor3 = Color3.fromHSV(hue, saturation, 1);
update();
end
Firing the Remote Event Script (LocalScript):
local Kart = script.Parent.Parent.Parent.ViewportFrame.Kart
local SpawnKartEvent = game.ReplicatedStorage.SpawnKartEvent
script.Parent.MouseButton1Click:Connect(function()
SpawnKartEvent:FireServer()
end)
ServerScript (Script):
local SpawnKartEvent = game.ReplicatedStorage.SpawnKartEvent
local Kart = game.StarterGui.ColorChanger.Frame.ViewportFrame.Kart
local color = game.StarterGui.ColorChanger.Frame.ScrollingFrame.ColourSelector.Colour.BackgroundColor3
SpawnKartEvent.OnServerEvent:Connect(function()
local clone = Kart:Clone()
clone.Parent = workspace
for i, v in ipairs(clone.Body:GetChildren()) do
v.Color = Kart.PrimaryPart.Color
end
end)
Place file: color changer.rbxl (44.9 KB)