Replacing default avatar with a game specific model

I am trying to create an asteroids-like top-down arcade shooter, but I am having trouble replacing the default avatar with my spaceship model

Here is the code I am using to replace the character model with the spaceship

-- Get a reference to the player's character
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer

-- get the default character
local defaultCharacter = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local defaultHumanoid = defaultCharacter:WaitForChild("Humanoid")
local defaultRootPart = defaultCharacter:WaitForChild("HumanoidRootPart")

-- load the spaceship that has the following heirarchy
----Spaceship (model)
------ Humanoid (a humanoid) Rootpart is HumanoidRootPart
------ HumanoidRootPart (a part)
local spaceshipModel = game.ReplicatedStorage.Spaceship:Clone()
local spaceshipHumanoid = spaceshipModel.Humanoid
local spaceshipRootPart = spaceshipModel.HumanoidRootPart

-- Wait for the new character to load
spaceshipModel.Parent = game.Workspace
while not spaceshipModel:IsDescendantOf(game.Workspace) do
	wait()
end
spaceshipModel:SetPrimaryPartCFrame(defaultCharacter:GetPrimaryPartCFrame())

-- replace players default humanoid with spaceships
spaceshipRootPart.Parent = defaultCharacter
spaceshipHumanoid.Parent = defaultCharacter

-- Destroy the old character model
defaultRootPart:Destroy()
defaultHumanoid:Destroy()

This code causes the spaceship to appear and the character to disappear briefly, then the spaceship disappears and the default character reappears.

I’m at a loss on how to replace the default avatar in the game. Any help would be appreciated

You can just set the players character to the model…

plr.Character  = model

Well, that was easy :slight_smile: Now the spaceship shakes randomly across the screen. Do you know what is going on?

Can you upload a picture of the character in the Explorer?

My spaceship right now is just a default part

Ah, that might be why, you need to add the limbs… You can add them and make them invisible.

Also, the part has to be unanchored, maybe…

I could, but I am trying to understand the best way forward. Here are the options I am considering:

  1. I could add limbs or create an entire humanoid rig that I would make invisible. This might be useful as it might allow me to reuse the default player controls.

  2. I anchor the spaceship with my own custom controls. Probably now a wise choice since there will most likely be other unforeseen problems down the road with this.

  3. I reuse the default character limbs and make them invisible. I am unsure on how to do that effectively.

Which option do you recommend?

hmmm… option 1 would be good… option 2 is good, but it will be difficult

Anchoring the model stops the jiggling of the part, unanchoring makes it jiggle

1 Like

Alright, thats good. Do you need help with anything else?

The anchoring stops the jiggle, but the controls don’t work. I’m assuming something is up with the physics configuration that might be addressed with limbs. If not then I will create my own controls

Alright, I was messing around with different configurations and get this… switching from an R15 to an R6 humanoid fixed the jiggle problem, and the default controls work perfectly. Thank you for your help!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.