Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I play as a single part?

Asked by 5 years ago

I'm trying to make a game where you are only a single sphere rather than a person, but I don't know how to do that. I've tried looking online for help, but I could only found out how to make controllable custom humanoids and not controllable objects. I also need help on where I put the scripts that make me control a sphere.

2 answers

Log in to vote
2
Answered by
xEmmalyx 285 Moderation Voter
5 years ago
Edited 5 years ago

A simple fix would be to use StarterCharacter and it will work perfectly!

EDIT : New Script/Method

Example

This is just my method and I'm sure there are many others that can be thought up

Example Rotation Script( Rotates Character Forwards )

Following Script Uses CFrame not BodyGyro/Velocity

local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")

local Player = game.Players.LocalPlayer
repeat wait() until Player.Character
repeat wait() until Player.Character.Humanoid
repeat wait() until Player.Character.HumanoidRootPart
local Character = Player.Character
local HumanoidRootPart = Character.HumanoidRootPart
local Humanoid = Character.Humanoid
Humanoid.AutoRotate = false


local W = false
local A = false
local S = false
local D = false
local Space = false

local Camera = workspace.CurrentCamera

local Mouse = Player:GetMouse()

local RotateSpeed = 3

RunService.RenderStepped:Connect(function()
    if(W == true) or (A == true) or (S == true) or (D == true) then
        local LookVector = Camera.CFrame.LookVector*RotateSpeed

        if W then
            Character.LowerTorso.Root.C1 = Character.LowerTorso.Root.C1 * CFrame.Angles(-math.rad(LookVector.Z),math.rad(LookVector.Y)*0,math.rad(LookVector.X))
        end

    end
end)


UIS.InputBegan:Connect(function(Input, Bool)
    if(Bool == false) then
        if(Input.KeyCode == Enum.KeyCode.W) then
            W = true
        end
    end
end)

UIS.InputEnded:Connect(function(Input, Bool)
    if(Bool == false) then
        if(Input.KeyCode == Enum.KeyCode.W) then
            W = false
        end
    end
end)
0
I get the ball to spawn correctly, but it keeps saying there is no head or PrimaryPart, and says head and torso can have an infinite yield. ReedyBuilder 0 — 5y
0
Click on the Model(StarterCharacter) and press PrimaryPart, then select HumanoidRootPart // for head and torso you could make the head an invisible part welded to the humanoidrootpart and make HumanoidRootPart Invisible. Same for Torso xEmmalyx 285 — 5y
0
I've tried what you've told me and put WeldConstraints on the Head and Torso. now the only error that pops up is "Infinite yield possible on 'Workspace.ReedyBuilder.Torso:WaitForChild("Right Shoulder")'". How do I fix that? ReedyBuilder 0 — 5y
0
Well you'd want to setup joints using the CustomCharacterCreator plugin. Learning how to use this will definitely help you out later on with anything such as custom characters or npcs xEmmalyx 285 — 5y
View all comments (9 more)
0
Got the plugin and put joints on all the parts. Infinite yield possible still shows up. ReedyBuilder 0 — 5y
0
Did you rename the joints to the proper joint? Right Arm + Torso Joint should be RightShoulder I believe xEmmalyx 285 — 5y
0
My model has just the HumanoidRootPart and the invisible head and torso. There shouldn't even be a right shoulder. ReedyBuilder 0 — 5y
0
Should I just ignore that infinite yield? ReedyBuilder 0 — 5y
0
I would, what script is that error appearing from? xEmmalyx 285 — 5y
0
The animate script in my player model. Also how do I insert those BodyVelocity or BodyGyros you originally mentioned? ReedyBuilder 0 — 5y
0
Put the Script that you sent me in. Now I got an error saying LowerTorso is not a valid member of Part, but I fixed it by changing LowerTorso to just Torso. Now it says that Root is not a valid member of Part. How do I fix that? ReedyBuilder 0 — 5y
0
View the example again, I fixed it up xEmmalyx 285 — 5y
0
Put your new script in. Nothing changed. It just gave me the same errors as last time. ReedyBuilder 0 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

Normally for performance reasons, as well as not having to deal with things like humanoid states for something that doesn't really have them, you want to uncheck the CharacterAutoLoads property of Players and just write a simple controller that maps user input to a force or velocity vector, for setting force or velocity on the ball (which could have a BodyVelocity or BodyForce object).

Most of the time, it's intuitive for a user's "foward" input (e.g. W key pressed) to contribute a force in the direction of game.Workspace.CurrentCamera.LookVector, or it's projection onto the ground plane, game.Workspace.CurrentCamera.LookVector * Vector3.new(1,0,1). Likewise, right and left controls map to forces (or velocity) in the direction of the camera RightVector, or opposite this, respectively.

Answer this question