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

Custom Character not working?

Asked by 9 years ago

Idea Disable the game from loading the characters Appearance, and then apply my own from a model.
Problem I get the following error ServerScriptService.Game_.Characters_.Disabler:4: attempt to call method 'Clone' (a nil value)
Code

game.Players.PlayerAdded:connect(function(Plr)
    Plr.CanLoadCharacterAppearance = false
 wait(5)
    game.ServerStorage.Char:GetChildren():Clone(Plr.Character)
end)

Thanks :D

1 answer

Log in to vote
0
Answered by
Hero_ic 502 Moderation Voter
9 years ago

This is not exactly how you would get a custom character. what you need to do is set the character to the custom character. Put the script in a localscript inside starterplayer.

wait(1)
local player --First we get the player
while not player do -- make sure we get the player.
    wait()
    player = game:GetService('Players').LocalPlayer
end
function onSpawn()
    local char = game.ReplicatedStorage["ModelName"]:Clone() --first we clone the new character either use ServerStorage or ReplicatedStorage. ( you decide :) )
    char.Parent = workspace --then we parent it to workspace
    char.Name = player.Name --next we can set it to the player's name

    local prevChar = player.Character --get the old character
    wait()
    player.Character = char --set it to the new one
    prevChar:Destroy() --destroy the old one

    if char:FindFirstChild("Humanoid") then
    char.Humanoid:Destroy() --destroy a humanoid if it already exists
    end
    local human = Instance.new("Humanoid", char) --Add a new humanoid
    char.Archivable = false --Set Archivable to false.

    human.Died:connect(function() --Now we create a respawn function
    wait(1) --change this to whatever time you want it to take to reload the character
    onSpawn()
    end)
end

onSpawn() --After all that we run the function.

That is all you need to do! but make sure you have already jointed every part of the character and have a head and torso and humanoid root part object!

if this helped please accept ~KIheros :)

0
Hey, Thanks this is great :D, anyway to make it a module so it can be accessed through another "main game" script? pluginfactory 463 — 9y
0
Maybe, not great at modules. :( Hero_ic 502 — 9y
0
Thats alright :D pluginfactory 463 — 9y
Ad

Answer this question