Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Spawning as random character?

Asked by 6 years ago

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.

0
????????????something like how fortnite does when you use have the default skins Davidm7r 0 — 6y
0
this is not a request site did u even try doing it Ecl0ox -7 — 6y
0
i did try doing it, i'm not just requesting i legitimately attempted it it didnt work Davidm7r 0 — 6y

1 answer

Log in to vote
0
Answered by
Optikk 499 Donator Moderation Voter
6 years ago

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)]
0
Oh and the CameraFixer part is because I ripped this from my own morph script. Optikk 499 — 6y
Ad

Answer this question