Currently working on some stuff which requires the spawning of a “decoy” model of the player upon their death, it seems to work, however, upon testing on a local server, the error “Invalid UserId” appears. I believe this might be caused as while testing with local server, UserIds are set as stuff such as -1, -2, and such. This might be the cause of the problem but I am unsure on wether it is, or if its just a problem with my script
for context, here is my script:
local function spawnPlayer(player)
--Irrelevant stuff
-- Proximity Prompt events
-- prox is a proximity prompt, ik that it works as the player is still able to die when it is activated
prox.Triggered:Connect(function()
player.Character.Humanoid.Health = 0
local inspectable = plrs:CreateHumanoidModelFromUserId(player.UserId)
inspectable.Parent = workspace
end)
--Irrelevant stuff
end
remoteEvent.OnServerEvent:Connect(spawnPlayer)
Yup, you are right, its because -1 its not a valid userID of an existant player in roblox.
If you need to run more tests in local server, you should change the approach of how you create the inspectable model.
What about, grabbing the HumanoidDescription when player joins, save it into a folder or table renaming it to the UserId, upon dead, use the userID find the proper HumanoidDescription, create a rig model and apply the HumanoidDescription to it, in that way, you are not getting the information from roblox, so it will work with userIds like -1, -2, etc
Yup, it works for normal roblox servers, and for the local server for testing. Its an approach I use in games when needing to get clones rigs from players
Applying a HumanoidDescription to a Dummy, or cloning the character of the player when player joins and clone that model and place it in workspace, any of both fired by a Humanoid.Died event or any custom event that you are using in your game, both ways are easy to do.
I prefer to not try to clone or get information from the player, or roblox website, when a player Humanoid.Died event triggers. I prefer to have the data ready saved somewhere. And when Humanoid.Died event triggers, just find that data saved previously and create the clones, rigs etc.
For example a podium, where I wont place the real players, just rigged clones using the winner’s HumanoidDescriptions, or character clones previously saved.
Less computing stuff at that moment if everything already exist, and deleting it when player leaves