#description wont apply output says invaild useid

1 messages · Page 1 of 1 (latest)

leaden flax
#

client script (local script)

local rs = game:GetService("ReplicatedStorage")
local Events = rs:WaitForChild("Events")
local TestingCommands = rs.Events:FindFirstChild("TestingCommands")

local function GetChosenPlayer()
    local players = Players:GetPlayers()
    if #players < 2 then
        return nil
    end
    return players[math.random(1, #players)]
end


for i = 20, 0, -1 do
    if #Players:GetPlayers() < 2 then return end
    script.Parent.Text = i .. " till the game starts"
    task.wait(1)
end


script.Parent.Text = "Starting..."
task.wait(2)


local chosenPlayer = nil
repeat
    chosenPlayer = GetChosenPlayer()
    task.wait(0.5)
until chosenPlayer ~= nil

if chosenPlayer then
    print("Chosen player:", chosenPlayer.Name)
    Events.GetRandomPlayerAndCreateCharacters:FireServer(chosenPlayer)
else
    warn("Not enough players")
end```
server script (script)
```local rs = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local events = rs:WaitForChild("Events")





events.GetRandomPlayerAndCreateCharacters.OnServerEvent:Connect(function(yes,player)
    print(player.UserId)
    
    
    

    local rig = workspace:FindFirstChild("Manger1")
    local humanoid = rig:FindFirstChild("Humanoid")

    local description = Players:GetHumanoidDescriptionFromUserId(player.UserId)
    
    humanoid:ApplyDescription(description)

    rig.Name = player.Name
end)

apply desciption doesnt work and output says incorrect user id please help

vague nebula
vague nebula
# leaden flax client script (local script) ```local Players = game:GetService("Players") local...

The problem arises because Roblox requires a UserId number, which causes GetHumanoidDescriptionFromUserId to throw "invalid userid" when your client sends a Player object to the server. Send the selected player to the client.UserId such as Remote:FireServer(selectedPlayer.UserId) is handled as remote on the server.OnServerEvent:Connect(function(sender, targetUserId)..." end). The issue will be resolved if you call Players:GetHumanoidDescriptionFromUserId(targetUserId) and apply that description to the Humanoid.

vague nebula
leaden flax
# vague nebula Here to help!

21:39:19.418 Unable to cast Instance to int64 - Server - CharacterAddingManager:18 but it just says this when i try to do chosenplayer.Userid in fire server argument

vague nebula
# leaden flax 21:39:19.418 Unable to cast Instance to int64 - Server - CharacterAddingManag...

You are receiving the "Unable to cast Instance to int64" problem because sending a Player object through a RemoteEvent in Roblox doesn't always communicate correctly. Instead, you should switch your FireServer call to Events and only give the UserId number.GetRandomPlayerAndCreateCharacters:FireServer(selectedPlayer.UserId), and utilize that UserId directly with Players on the server side:Given that it is already a number, GetHumanoidDescriptionFromUserId(chosenUserId). While complete Player instances may result in type conversion problems, this method works because numbers communicate flawlessly over the client-server border.

leaden flax
waxen yokeBOT
#

studio** You are now Level 3! **studio

vague nebula
# leaden flax i did that before and it still types thos

The chosenPlayer itself may be null or invalid when you attempt to access, which is probably why the issue is occurring.UserId, thus before starting the server, add a safety check: if chosenPlayer and chosenPlayer:IsA ("Player") then Events.GetRandomPlayerAndCreateCharacters: FireServer(selectedPlayer.UserId); else, an error message stating "Invalid player selected" is displayed. To observe what kind of data is truly arriving, provide debug prints at the beginning of your OnServerEvent function on the server side: print ("Received:", receivedData, "Type:", typeof(receivedData)) will indicate whether you are receiving the intended number or anything different. If something other than "number" appears as the type, the client's chosenPlayer is the problem.Before being sent, UserId is not being evaluated to a number.