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

How do you constantly spin a players character?

Asked by 5 years ago
Edited 5 years ago

Hello,

Context - I am trying to make a !spin player command for my game. I have removed the internal command system code from this question for simplicity.

Problem: - The player doesn't spin correctly. Using multiple methods to spin the player, I cannot get the player to spin.

Attempt 1: - My first method was using CFrame, with this code being run for the HumanoidRootPart:

hum.HumanoidRootPart.CFrame = hum.HumanoidRootPart.CFrame * CFrame.fromEulerAnglesXYZ(0,-0.1,0,0)

This code spins the player. However, the player is stuck in a fixed position (the player cannot move while spinning).

Attempt 2: - The second method was using a BodyGyro. I used the following code to create the BodyGyro and to customise it for spinning the character:

local BodyGyro = Instance.new('BodyGyro', hum.FindFirstChild("HumanoidRootPart")) 
BodyGyro.P = 10000
BodyGyro.D = 1000
BodyGyro.MaxTorque.Y = 300

while true do
    BodyGyro.CFrame = CFrame.new(0,90,0)
    wait(0.15)
    BodyGyro.CFrame = CFrame.new(0,180,0)
    wait(0.15)
    BodyGyro.CFrame = CFrame.new(0,270,0)
    wait(0.15)
    BodyGyro.CFrame = CFrame.new(0,360,0)
    wait(0.15)
end

This spins the character away from the camera. Then stops spinning. I tried to fix this problem by adding a change in CFrame every 0.15 seconds, as shown in the code above. This does not fix the issue.

I do not know how to solve this problem. Any advice or solutions you have would be appreciated.

Tweakified

1 answer

Log in to vote
2
Answered by
OnaKat 444 Moderation Voter
5 years ago

Using BodyAngularVelocity!

local BodyAngularVelocity = Instance.new('BodyAngularVelocity', hum:FindFirstChild("HumanoidRootPart"))
BodyAngularVelocity.AngularVelocity = Vector3.new(0,10,0)             --Change Speed(10) Here!
Ad

Answer this question