How to make the starter character a ball that rolls?

Heyo devforum! I have a question for everyone today! How would I make the character spawn in as a ball, and that ball would actually roll as well? Here a YouTube video of what I am trying to achieve!:

Thanks in advance!

8 Likes

I’ve never done anything like this, but it should just be you welding the characters Torso or (UpperTorso if you’re using R15), to the sphere.

local Char = script.Parent
local Ball = PATH_TO_BALL:Clone()

local Weld = Instance.new("WeldConstraint")
Weld.Parent = Ball
Weld.Part0 = Ball
Weld.Part1 = Char.HumanoidRootPart

Ball.Position = Char.PrimaryPart.Position + Vector3.new(0, 0, 0)
Ball.Parent = Char

Regular script inside of StarterCharacterScripts

Also, the ball currently doesn’t let you move, you probably should disable the player movement and only use body movers to make the ball move around with custom movement.

5 Likes

To make a player spawn in a ball, you’d need to do one of two things:

Clone the player model, position and weld the model to the ball if unanchored / position, anchor, and child the model to the ball if anchored. Set the player’s currentcamera.camerasubject to the ball.

or

Take the player’s model, remove all animations, and weld it to the ball.

In terms of making the ball roll, you can go about it a number of ways. One of the best ways is to use

to apply acceleration to the ball in directions you want it to go, and for jumping, apply velocity instead of acceleration.

Here’s a way you could go about taking user inputs:

function beginRecordingInputs(PlayerWrapper)
UserInputService.InputBegan:Connect(function(input, gameProcessed)
	if input.UserInputType == Enum.UserInputType.Keyboard then
		local KeyPressed = input.KeyCode
		if KeyPressed == Enum.KeyCode.W then
			ball.BodyForce.Force = ball.BodyForce.Force + (camera.CFrame.LookVector * Vector3.new(1,0,1))
		end
    end
end)
end

While the above code I wrote gets the right idea (using user input to change acceleration) This solution is not something i would use, because instead of applying a small change to the force when they press W, you’d want to apply a small change every RenderStep when they hold a key and then stop applying it when they let go, while also factoring in friction to slow the ball down when they aren’t holding a key. This, and you’d want to make sure that these client side inputs are secured on the server. But these are things you should look into on your own.

I’ll link a few articles that i think will help.

16 Likes

Thank you! This was very helpful! And thank you @Pavalineox for giving a in-depth explanation aswell!

2 Likes

Hmm why do you put UserInputService on a function?

1 Like

@EgoMoose created a demo for this kind of thing before, if you’re interested. It’s open source and includes the behaviour you’re looking for. Probably.
https://www.roblox.com/games/3439178421/Super-Primate-Ball

Consult this thread as well, as it is on the same topic:

6 Likes

I copied that code from one of my projects where it is contained in a modulescript. It’s purely because our code follows a declaratory philosophy on all methods.

2 Likes

Sorry for bumping this thread, but I had the same genuine question. I’ve done this process, yet, as the ball is thrusted via body movers, it wants to stay upright due to the players humanoid.

Code

game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(Char)
local Weld = Instance.new(“WeldConstraint”)
Weld.Parent = workspace
local Marble = Instance.new(“Part”)
local BodyForce = Instance.new(“BodyForce”,Marble)
BodyForce.Force = Vector3.new(0,1,50)
Marble.Shape = “Ball”
Marble.Position = Vector3.new(10,10,10)
Marble.Size = Vector3.new(10,10,10)
Marble.Anchored = false
Marble.Massless = true
Marble.Parent = workspace
Char.Archivable = true
local Dummy = Char:Clone()
Dummy:WaitForChild(“HumanoidRootPart”).CFrame = CFrame.new(Marble.Position)
Dummy.Parent = workspace

		Weld.Part0 = Dummy.HumanoidRootPart
		Weld.Part1 = Marble
	end)
end)

other than that, your explanation makes a ton of sense , this is the only part i’m truly stuck on.

A player humanoid will naturally resist forces since ROBLOX’s humanoids use physics to move.

Setting HumanoidStateType to Physics will stop the humanoid from applying forces on itself

2 Likes