How to check part's rotational velocity

I’ve wrote some code to damage a player and spin a part but when I print the velocity it gives 0,0,0

local CS = game:GetService("CollectionService")

local Lasers = CS:GetTagged("Laser")

local Config = {
	NormSpinSpd = 0.01;
	Damage = 25;
	DamageDelay = 0.75;
}

game.Players.PlayerAdded:Connect(function(plr)
	
	plr:SetAttribute("LaserDB",false)
	
end)

for _, Laser in pairs(Lasers) do
	
	Laser.Touched:Connect(function(hit)
		
		if hit.Parent:FindFirstChild("Humanoid") then
			
			local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
			
			if plr and plr:GetAttribute("LaserDB") == false then
				
				hit.Parent.Humanoid.Health -= Config.Damage
				
				plr:SetAttribute("LaserDB",true)
				
				task.wait(Config.DamageDelay)
				
				plr:SetAttribute("LaserDB",false)
				
			end
			
		end
		
	end)
	
end

while true do
	
	script.Parent.Main.Laser.CFrame = script.Parent.Main.Laser.CFrame * CFrame.Angles(0,-Config.NormSpinSpd,0)
	
	print(script.Parent.Main.Root.AssemblyAngularVelocity)
	
	task.wait()
	
end

By setting the part’s cframe directly you’re effectively just teleporting the part. From it’s point of view, it’s just being teleported very quickly, making it look as if it’s rotating while it’s actual velocity is 0.

how would i be able to measure how fast i am teleporting it

We already know based on the values you’ve provided it that you’re rotating it by -Config.NormSpinSpd (in radians) every frame.

Velocity stuff isn’t being set. You’re changing rotation but not the physics velocity. You’re not using Delta time so the speed varies with lag, but it’s approximately NormSpinSpeed / math.pi * 648000 RPM.

1 Like

yeah but 0.01 is fast so how would i turn it into a something like 1

1 Like

Well for starters you’re setting it every frame, it’d be better if we could do things consistently across multiple framerates.

local rotationInDegreesEverySecond = 90
local rotationInRadians = math.rad(rotationInDegreesEverySecond)

game:GetService("RunService").Heartbeat:Connect(function(deltaTime)
	script.Parent.Main.Laser.CFrame *= CFrame.Angles(0, rotationInRadians * deltaTime, 0)
end)
2 Likes

I gave you the formula for RPM, just reverse it.

NormSpinSpeed = math.pi / 648000

1 Like

this would need to be localscript tho?

Yeah if you want the rotation to be smooth on everyone’s end the visual effect should exist on everyone’s client

1 Like

how could i do rps (rolls per sec)

360 is a full rotation in degrees if you use the script i sent earlier