Character won't change when I use character appearance ID

(Disclaimer: This is the last post I will ever make on the devForums)

So here is what the player does, there is a textbox, player enters userid, player presses change char button, doesn’t work.

It is so annoying, it hasn’t been working for 40 minutes now.

Code (The Event Code [In A Server Script])

game.ReplicatedStorage.ChangeChar.OnServerInvoke = function(id, player)
	local idMain = tonumber(id)
	
	player.CharacterAppearanceId = idMain
	player:LoadCharacter()
end

Code 2 (The UserId getter and event fire-er [In A Local Script])

script.Parent.MouseButton1Click:Connect(function(changeChar)
	local id = tonumber(script.Parent.Parent.Input.Text)
	
	local player = game.Players.LocalPlayer
	game.ReplicatedStorage.ChangeChar:InvokeServer(id, player)
end)

Please help, this has been happening 40 minutes (like I said) and is giving me a coding headache

This is the error that it returns:

Attempt to index number with 'CharacterAppearanceId'

Swap your arguments on the OnServerInvoke function. It should be player, id.

And when invoking it, you don’t need to pass the player, just use InvokeServer(id).

Remote events and functions pass the calling client as the first argument on the server connections.

3 Likes

OMG thank you so much, you do not know how much you helped me there :smiley:

Thank you so so SO much :slight_smile: