So i'm working on a game where I want you to automatically onentered change the player into a model i made which i inserted an humanoid and head object into.
I was wondering if there is a way to pull this off? basically what i'm trying to say is how to change the player to a different object. I've been looking this up over and over and found nothing. :/
Model. http://i.imgur.com/CCFfVzH.png
SHORT ANSWER: Upon entering the server, you could redefine the Character property in the Player instance.
LONG ANSWER: There are some guidelines you may need to follow to make a functional Character object.
SCRIPT
.PlayerAdded
and .CharacterAdded
, because this will be the fundamental element to transform the Character object.-- Ideally, you should put this in game.ServerScriptService. game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) -- This is where the magic happens. end) end)
game.ServerStorage
).CHARACTER
As mentioned before, store the Character object in a storage instance (skip this if you're just going to create a script for the transformation). Anchor all of the parts.
In order to sustain the life of your Character object, a head/torso MUST be connected (Motor6D) and a HumanoidRootPart MUST be present. Refer to the default Robloxian Character object and see where the Motor6D joint objects connect to.
In my experience, keeping a Humanoid object in the Character object in Studio never worked out, as I keep dying. So in your script, create a new Humanoid object onto the Character.
Now all you have to do is make a spawn point for your character (with CFrame), rename the Character object every time it spawns, and then you're pretty much done.
This is how you redefine a Character object, add the Humanoid object in, and rename your character:
-- If your Character object is in game.ServerStorage newCharacter = game.ServerStorage.YourCharacterObject:Clone() newCharacter.Parent = workspace newCharacter.Name = Player.Name Player.Character = newCharacter Humanoid = Instance.new("Humanoid", newCharacter) newCharacter.Archivable = false