Greetings! I am working on a system that changes a brick's color from a gui. For some reason it errors?

ServerScriptService.Script:7: invalid argument #3 (BrickColor expected, got Instance)

Here are the scripts I am using:

LocalScript:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local green = ReplicatedStorage:WaitForChild("Green")


script.Parent.MouseButton1Down:Connect(function(partColor)
	green:FireServer(BrickColor.Red())
end)

Server-Side script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remoteEvent = ReplicatedStorage:WaitForChild("Green")


local function a(partColor)
	game.Workspace.Part.BrickColor = partColor -- <- errors here
end

remoteEvent.OnServerEvent:Connect(a)

What could be the mistake? All help is appreciated!

2 comments

2

Hey. This is because when you do :FireServer(), the Player argument is automatically passed as the first argument. So you need to be doing local function a(Player, partColor)

0

Oh wow! You're right, thank you! :) Didn't know that was needed! Thanks for the help again!