Unable to cast instance to int64

Hello, I am trying to make an outfit loader where players can type in someone else’s user name and load in their outfit. For some reason though, I get this error, “Unable to cast instance to int64” in the 4th line of my script (server). I cannot think of any solutions, why might this be happening?

Local script:

local plr = game.Players.LocalPlayer
local button = script.Parent
local input = button.Parent.Input
local event = game.ReplicatedStorage.LoadPlayerOutfit

	local success, errormessage = pcall(function()
		return game.Players:GetUserIdFromNameAsync(input.Text)
	if success then
		event:FireServer(plr, game.Players:GetUserIdFromNameAsync(input.Text))


local event = game.ReplicatedStorage.LoadPlayerOutfit

event.OnServerEvent:Connect(function(plr, ID)
	local desc = game.Players:GetHumanoidDescriptionFromUserId(game.Players:GetHumanoidDescriptionFromUserId(ID))

Thanks for reading!

you used the same function twice.

This would be your Issue.

What GetHumanoidDescriptionFromUserId does is return a HumanoiDescription based on the UserId given, what the error means by int64 is a 64 bit signed integer, which is a whole number that has a limit of 2^63 - 1, what the function is getting is the exact same function that is either returning nil, or a HumanoidDescription, which arent numbers, the function sees that they arent numbers, and gives the error: Unable to cast instance to int64, which if you notice Instance, that means it returned a HumanoidDescription, so you need to remove one of the functions.

I figured out the problem myself, although yes, GetHumanoidDescription() returns an Instance. I decided to test something out. In my local script, I replaced the first fireserver() parameter with “Hi” and had my script print that parameter out. I got “Berrinlin” printed instead, which is my username. Apparently, OnServerEvent functions take an extra parameter which is the player who’s local script called the server event.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.