Remote event giving error

I am trying to make the players role change when he/she joins the game.

error → ServerScriptService.RoleChangeEventScript:8: invalid argument #3 (string expected, got boolean)

server script

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remoteEvent = ReplicatedStorage:WaitForChild("ChefRoleChangeEvent")

-- Create a new part
local function onChangeRole(player, stringvalue)
	print(player.Name .. " fired the remote event")
player.Role.Value = stringvalue
end

-- Call "onCreatePart()" when the client fires the remote event
remoteEvent.OnServerEvent:Connect(onChangeRole)

local script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local stringvalue = ""
local remoteEvent = ReplicatedStorage:WaitForChild("ChefRoleChangeEvent")
-- Include additional data when firing the event

remoteEvent:FireServer(stringvalue == "Chef")
1 Like

stringvalue == "Chef" returns a false/true boolean. You didn’t specified what you’re trying to achieve, but assuming you’re wanting to change a StringValue parented to the player to a new role, just specify the role when declaring the variable.

local stringvalue = "Chef"