How come the color isn't being put into the model correctly?

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 so the color is put onto the model with the correct coding.

  2. What is the issue? Include screenshots / videos if possible!
    Say I want the color of the model, to be white so I put 255, 255, 255 but it inserts as 0, 255, 255.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried looking for solutions, but I couldn’t find anything that had the same issue.

Local Script

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

script.Parent.MouseButton1Click:Connect(function()
	Event:FireServer(script.Parent.Parent.RBOX.Text, script.Parent.Parent.GBOX.Text, script.Parent.Parent.BBOX.Text)
end)

ServerScript

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

Event.OnServerEvent:Connect(function(R, G, B)
	player.Character.Tool.Handle.Color = Color3.fromRGB(R, G, B)
end)
Event.OnServerEvent:Connect(function(player,R,G,B)
1 Like

What should put in the LocalScript though?

Local script looks good. If you are only getting 2 of the three colors, its because you were assigning R to the player who sent the event, and that was on server.

So just change the line I gave you for the server code, and it should work

I just put game.Players.LocalPlayer for “player” part. Still isn’t working.

Show me your modified code.

Client and Server, please

LocalScript

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

script.Parent.MouseButton1Click:Connect(function()
	Event:FireServer(game.Players.LocalPlayer, script.Parent.Parent.RBOX.Text, script.Parent.Parent.GBOX.Text, script.Parent.Parent.BBOX.Text)
end)

ServerScript

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

Event.OnServerEvent:Connect(function(player, R, G, B)
	player.Character.Tool.Handle.Color = Color3.fromRGB(R, G, B)
end)

In the LocalScript have it …

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

Roblox adds the ‘player’ attribute automatically for you, you don’t need to add it.

1 Like

Oh, I didn’t know that! Is the player part always needed?

When you fire an event from the client, to the server, you never have to Send the player event to the server, but the server always needs to Receive the player

So yes, always.

2 Likes

You also may need to remove the other player variable referencing the player added at the second line on the server script.

2 Likes