Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Spawning as random character?

How do i make it so that my players spawn as random characters each time they play? I've looked everywhere but can't find an answer.

3 comments

0

????????????something like how fortnite does when you use have the default skins

0

this is not a request site did u even try doing it

0

i did try doing it, i'm not just requesting i legitimately attempted it it didnt work

1 answer

You could use a morph function, like the one below, and morph them into a random character.

function MorphPlayer(Player, Morph)
	Player:ClearCharacterAppearance()
	
	local CurrentCharacter = Player.Character
	local CurrentHumanoid = CurrentCharacter:WaitForChild('Humanoid')
	local OriginalCFrame = CurrentCharacter.HumanoidRootPart.CFrame
	
	local CharacterMorph = Morph:Clone()
	
	CharacterMorph.Parent = workspace
	CharacterMorph.Name = Player.Name
	
	Player.Character = CharacterMorph
	
	CurrentCharacter:Destroy()
	CurrentCharacter = Player.Character
	CurrentHumanoid = CurrentCharacter.Humanoid
	
	repeat wait() until Player.Character == CharacterMorph

	local CameraFixer = script.CameraFixerScript:Clone()
	CameraFixer.Parent = Player.PlayerGui
	
	CurrentCharacter.Animate.Disabled = true
	wait(.1)
	CurrentCharacter.Animate.Disabled = false
	CurrentCharacter.HumanoidRootPart.CFrame = OriginalCFrame
end

Event for when players spawn: API:Class/Player/CharacterAdded

You can pick a random element of a folder (for picking the morph) by doing something like this:

local Morphs = game.ServerStorage:WaitForChild('Morphs'):GetChildren()
local RandomMorph = Morphs[math.random(#Morphs)]

1 comment

0

Oh and the CameraFixer part is because I ripped this from my own morph script.

This discussion is preserved as it was. New answers, comments, and votes are closed.