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

Making a player use a custom character? UNANSWERED

Asked by 9 years ago

Goulstem's method crashes the server


Let's just say there's a model called Bob in the lighting and it has a armor welded to its torso.

game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character)
local bob = game.Lighting.Bob

Now I wanted the player to spawn as Bob so do I clone Bob and move his components to the player and delete the player's limbs? Help!

2 answers

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

Destroy the character when it spawns, set the character property of the Player to that model.

The model must have the appropriate children for it to work - Head, and Humanoid. If you want it to be able to walk and stuff then Clone the Animate localscript and place it into the new character, but make sure you have Arms and Legs in your model

Also, Lighting isn't meant to be used for storage, use ServerStorage.

Example;

local model = game.ServerStorage.Bob --Model

game.Players.PlayerAdded:connect(function(plr)
    plr.CharacterAdded:connect(function(char)
        local anim = char:WaitForChild('Animate'):Clone()
        char:Destroy()
        local newChar = model:Clone()
        anim.Parent = newChar
        newChar.Parent = workspace
        plr.Character = newChar
    end)
end)
0
woops, the server crashes as well,but on the test version a message pops out and shows this "Error on visit: The Parent property of Player is locked, current parent: NULL, new parent Workspace" SomeoneYetUnnoticed 31 — 9y
2
@SomeoneYetUnnoticed Play around with it. After all, it's an example script. One thing I will say though, try and move line 6 after line 10. Redbullusa 1580 — 9y
Ad
Log in to vote
0
Answered by
debugd 5
9 years ago

I'd like to know more about this too. I've experimented with different possibilities without success. I have changed the nested anonymous functions to just one anonymous function. That seems to get rid of the infinite recursing error thrown by the code @Goulstem posted.

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:wait()
    -- magic goes here to use a different model as the character
end)

Can anyone provide some code that works? Thanks!

Answer this question