Help me to move while spinning

So, I made this script (that worked first time, omg) that made you spin around in a calm velocity when you chat “spin”. What I want is that when this happens, I want it that you can still move around while spinning. Right now when I spin you just stay in place, and when you try to move you kinda glitch into place and just keep spinning.

Anyway, here’s the code.

local a = 0
local antiStack = false

game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
		if msg == msg.lower("spin") and antiStack == false then
			if plr.Character:WaitForChild("HumanoidRootPart") then
				antiStack = true
				local plrchar = plr.Character.HumanoidRootPart
				while wait(0.03) do
					plrchar.Rotation = Vector3.new( 0, a, 0)
					a = a+3
				end
			end
		end
	end)
end)

Reason I put this here is because I have no issues with the code, rather just want to improve already working code

What is this for loop for? Im not seeing any references of plrdes in that for loop

i knew someone would ask this, in roblox you can chat as soon as you get in the game. so i wanted the character to actually be added to prevent any issues with characrers

sometimes your character is added way too late

Can’t you just use Character:WaitForChild(“HumanoidRootPart”)? Or any other way because the while loop will be ran multiple times thus resulting in your character moving in a glitchy way

1 Like

okay, yeah i removed the loop, now what do i do

Test it and see if it works now.

1 Like

so you thought the loop would mess with the animations, sadly that isnt the case. i still stay in place

Try putting task.wait(0.03) at the beginning of the while loop

you mean after the while?
while task.wait(0,03) true do ??

Yes, also its while task.wait(0.03) do

1 Like

ok ,ill update the main post. look at the code, it should change any second

so? do you have any idea to fix this?

Maybe try using an animation this might allow it to work

Blockquote
local a = 0
local antiStack = false

game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
if msg == msg.lower(“spin”) and antiStack == false then
for _,plr in pairs(game.Players:GetChildren()) do
spawn(function()
local Character = plr.Character
for _,d in pairs(Character:GetDescendants()) do
if d:IsA(“BasePart”) then
spawn(function()
local angularVelocity = Instance.new(“BodyAngularVelocity”,d)
a += 3
angularVelocity.AngularVelocity = Vector3.new(0, 1, 0) * math.rad(nil*a)
end)
end
end
end)
end
end
end)
end)

Yeah thanks for helping but, what is the “d” in the code. And where does the angularVelocity go?

nevermind, i found where it goes. kinda weird to get a whole new set of code that i didnt write. thanks for the help :heart:

no problem at all
Tbh it took some time