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
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
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
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)