I’m trying to make a random character picker when you die. For example, you die in ROBLOX, you get a different character with the .Died
function, but how do I change their character?
Do you mean when someone dies they, like, morph into a different character?
Died is an event, not a function btw.
Let’s say you have a character and a remote event in replicated storage, maybe this will work:
-- Should be in a server script
local Player = --However your getting the player
local Humanoid = Player.Character.Humanoid
Humanoid.Died:Connect(function()
local Pos = Humanoid.Parent.HumanoidRootPart.Position
Player.CharacterAdded:Wait()
local New_Character = game.ReplicatedStorage.NewCharacter:Clone()
New_Character.Parent = workspace
New_Character.HumanoidRootPart.Position = Pos + Vector3.new(0,0,5)
game.ReplicatedStorage.RemoteEvent:FireClient(Player, New_Character)
end)
--This should be on the client
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function(New_Character)
local Player = game.Players.LocalPlayer
local Old_Char = Player.Character
Player.Character = New_Character
Old_Char:Destroy()
local Camera = game.Workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Scriptable
Camera.Subject = New_Character
end)
This probably won’t work, but test it and let me know.
Or you could use a HumanoidDescription
instance.
1 Like
Can I please have an example of HumanoidDescription?
It also didn’t work sorry!
What errors did u get? posodwwadw
I got no errors at all? This seems kinda weird.
I’m using R15, is there a way to do it instead of R6?