Change character when pressing F

Hi everybody!
What I’m trying to achieve is as soon as the player flies that he changes character! What I have now is that if the player presses F then you fly and that works perfectly.
I know that as soon as I place a StarterCharacter in starterplayer it will automatically change to that character but I only want this to happen when I press F and the player flies.

The flying character is actually a kind of light ball. And now have the flying character transparent arms, legs, torso and head. so my question is does a character have to have a specific head, legs and arms or can I just use Torso or HumanoidRootPart without the head,leg and arms?

Unfortunately I’m not good at programming yet and would therefore like your help!
This here below is my simple fly script:


repeat wait() until game.Players.LocalPlayer.Character

local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local torso = character:WaitForChild("LowerTorso")
local mouse = player:GetMouse()

local enabled = false

mouse.KeyDown:Connect(function(key)
	if key == "f" then
		if enabled == false then
			enabled = true
			local bodyvelocity = Instance.new("BodyVelocity", torso)
			bodyvelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
			
			while enabled == true do
				bodyvelocity.Velocity = mouse.Hit.LookVector * 100
				wait()
			end
		end
		
		if enabled == true then
			enabled = false
			torso:FindFirstChild("BodyVelocity"):Destroy()
		end
	end
end)
1 Like

idk what u mean by that, but yes. a character does need to have a head or it is gonna die

1 Like

HumanoidRootPart, Torso, Head are mandatory for your character, luckily you can set their transparency to 1 if ever needed to hide them.

2 Likes

Thank you! So now I have a nice character that I want to change if the player is flying. How can I change the character? So as I told I only want to change it when the player is pressing F

1 Like

I believe loadcharacter might help you with that although I do suggest taking a look at some ‘shop tutorials’ they’ll show how to load a character into a customized one! I haven’t done this but I know mandatory requirements lol sorry!

2 Likes

Unfortunately I can’t find anything how to change it.

I even looked at animations to see if they could do something with it, but that doesn’t work.
So what I have is the main character that looks like your own character. And if someone is pressing F the player starts flying. And I want to change the players character to a specific character what looks like a glowing light

Hopefully somebody can help me!

1 Like

I believe you can manually set the player’s character to a new character model, effectively changing their appearance. This has to be done on the server, and you’ll have to set the camera’s subject to the new character model, but it should work.

2 Likes

I’m looking on the internet and youtube for the solution, without success. Hopefully did someone else this and could help me. In the meantime I will keep searching for a solution. p.s. I saw something about “HumanoidDescription”? Maybe is this the solution?

1 Like

Did you try what I posted? Set player.Character to the model you want it to be, then set the CurrentCamera.Subject to that model’s humanoid.

1 Like

Yes I tried it. But when i do

mouse.KeyDown:Connect(function(key)
	if key == "f" then
		if enabled == false then
			enabled = true
			local bodyvelocity = Instance.new("BodyVelocity", torso)
			bodyvelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
			while enabled == true do
				character = game.Workspace.StarterCharacter:Clone()
				workspace.CurrentCamera.CameraSubject = humanoid
				bodyvelocity.Velocity = mouse.Hit.LookVector * 100
				wait()
			end
		end

it wont change the character.

Then what I tried was first above
character = game.Workspace.StarterCharacter:Clone()

to first Destroy() the Character but then I cant move and get a error message
Player:Move called, but player currently has no humanoid. (x45) - Studio

So what am I doing wrong? (the StarterCharacter has humanoid and humanoidrootpart in it)

You’re not setting Player.Character.

1 Like

uhm, sorry did not upload the peace above it:

local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local torso = character:WaitForChild("LowerTorso")
local mouse = player:GetMouse()
local enabled = false

mouse.KeyDown:Connect(function(key)
	if key == "f" then
		if enabled == false then
			enabled = true
			local bodyvelocity = Instance.new("BodyVelocity", torso)
			bodyvelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
			while enabled == true do
				character:Destroy()
				character = game.Workspace.StarterCharacter:Clone()
				workspace.CurrentCamera.CameraSubject = humanoid
				bodyvelocity.Velocity = mouse.Hit.LookVector * 100
				wait()
			end
		end

You’re still not setting player.Character lol

1 Like

So what do I need to do then? Maybe you can tell it perhaps?

You’re only setting the variable. You need to explicitly set player.Character = game.Workspace.StarterCharacter

In your case here, doing character = StarterCharacter is setting the variable you created in the script, while what you need to do is set the player’s character property directly.

1 Like

Thank you that works.

So what I have now is:

mouse.KeyDown:Connect(function(key)
	if key == "f" then
		if enabled == false then
			enabled = true
			local bodyvelocity = Instance.new("BodyVelocity", torso)
			bodyvelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
			while enabled == true do
				
				player.Character = game.Workspace.StarterCharacter:Clone()
				workspace.CurrentCamera.CameraSubject = humanoid
				bodyvelocity.Velocity = mouse.Hit.LookVector * 100
				wait()
			end
		end

Only problem now is that it wont give me any errors. But the camera is broken as you said and after 2 sec the player respawned (probably because of no head/body)

So could you help me further?

The character is invisible*

Make sure you’re setting the camera to the new character’s humanoid: in the code snippet you sent me, you seem to be setting it to the old humanoid.

As for the player respawning, make sure your new character is a valid startercharacter, with all its joints set properly.

1 Like

Now I can see the new character. The camera doesnt work yet but it now changes to the new character

	
				player.Character = game.Workspace.StarterCharacter:Clone()
				local newCharacter = player.Character
				workspace.CurrentCamera.CameraSubject = newCharacter.Humanoid


The “old” character flies away and still moves when I try and fly away?

You’re also setting player.Character to a clone of StarterCharacter, but the clone’s parent is never set.
You should be doing this:

local newCharacter = workspace.StarterCharacter:Clone()
newCharacter.Parent = workspace
player.Character = newCharacter
workspace.CurrentCamera.CameraSubject = newCharacter.Humanoid

If you’re not using the old character anymore, make sure to destroy it after setting the new character.

1 Like

I used your code but then every half sec the newcharacter spawns in with like 300 characters,

			while enabled == true do
				local newCharacter = workspace.StarterCharacter:Clone()
				newCharacter.Parent = workspace
				player.Character = newCharacter
				workspace.CurrentCamera.CameraSubject = newCharacter.Humanoid
				bodyvelocity.Velocity = mouse.Hit.LookVector * 100
				wait()
			end

The only reason why the character needs to change is because the player can fly.
After pressing F again the the fly character needs to change with the old one…