Custom Character Problem

Hello everyone,
I am making a custom character and I have seemed to run into a problem. The education.roblox mentions to use weld constraints to weld the parts to the humanoid, but when I did that and tried to play none of the controls seems to work. Previously I wrote my code using a single part and worked perfectly. The script I made for the character makes the character like a spaceship and it made it fly. Now with the new character, the spaceship does not fly. I tried adjusting the body velocity and adding more speed, but no luck.

image

Ask if I need to add more info or need to clarify.
Thanks for the Help!

2 Likes

Can you provide the file for the model of the character? I just did a quick test with a single part and am able to control it fine.

image

Here is the model:
image

image

Sorry, I meant the model file so I can perform a reproduction test in my studio to make sure we’re doing the same things.

oh, how do I do that, export the .obj file here?

You can right-click the model and “Save to file”

Both files are the same thing:

The .rbxm file
SpaceShip.rbxm (5.5 KB)

The .obj file:
Space.obj (11.4 KB)

Also, do you need my player script?

Possibly. Because I just tested your model and I can control it just fine.

yeah, but my player script, I wrote it, is not working like intended when there are more than one part; u can try it with one part vs multiple parts.

Code:

local Controls = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule")):GetControls()
Controls:Disable()

local RunService = game:GetService("RunService")
local userInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer

local character = player.Character or player.CharacterAdded:Wait()
local hrp = character:WaitForChild("HumanoidRootPart")
player.CharacterAdded:Connect(function(char)
	hrp = char:WaitForChild("HumanoidRootPart")
end)


local mouse = player:GetMouse()
local mouse_x = mouse.Hit.X
local mouse_y = mouse.Hit.Y
local mouse_z = mouse.Hit.Z
local b_gyro = hrp:WaitForChild("BodyGyro")
local b_velocity = hrp:WaitForChild("BodyVelocity")
local lv

local forward_key = Enum.KeyCode.W
local holding
local speed = 1250
b_velocity.Velocity = Vector3.new(0,0,0)


userInputService.InputBegan:Connect(function(input, gameProcessedEvent)
	if input.KeyCode == forward_key then 
		holding = true 
	end

	while holding == true do
		b_gyro.CFrame = CFrame.new(hrp.Position,mouse.Hit.p)
		lv = b_gyro.CFrame.LookVector
		b_velocity.Velocity = Vector3.new(lv.X * speed, lv.Y * speed, lv.Z * speed)
		wait()
	end
end)



userInputService.InputEnded:Connect(function(input, gameProcessedEvent)
	if input.KeyCode == forward_key then 
		holding = false
		repeat
			b_velocity.Velocity = b_velocity.Velocity * 0.983
			wait()
		until b_velocity.Velocity == Vector3.new(0,0,0)
	end
end)

function GetDeltaTime()
	local current = tick()
	return tick() - current
end

while true do	
	b_gyro.CFrame = CFrame.new(hrp.Position,mouse.Hit.p)
	lv = b_gyro.CFrame.LookVector	
	RunService.Heartbeat:Wait()
end
	
	
	
	
	
	

You can just get a working fly script and add to your character.

Um, @testingacc333330, the code works when the character only has a single part, but when more parts are introduced (such as a spaceship) the code doesn’t work

Have you tried adding :GetChildren()?

@testingacc333330, this issue is related to custom character, :GetChildre() will not do anything, since the humanoid root part (hrp) is the one that controls the characters. For example, hrp in the default character, controls the rotation and the position of rest of the body. To elaborate, when the hrp moves forward, the arm moves automatically and so does the other body parts. Custom character has different properties, here is a link: https://education.roblox.com/en-us/resources/education/arcade/customCharacter.

It’s because your BodyVelocity needs a higher MaxForce

image

That works, is it because more parts = more mass?

Correct, it is. The Roblox physics engine calls joined objects one “system” and the total mass is considered when applying physics to a system.

ah… Thanks for the help @MrNicNac!

1 Like