Framerate effecting gun recoil

144 fps creates a much higher recoil experience than 60 fps. I know this has something to do with delta time to make sure things can’t update more often then they should but I don’t know.
video:


code:

runservice.RenderStepped:Connect(function(dt)
	if char:FindFirstChildOfClass("Tool") and char.PrimaryPart and camera:FindFirstChildOfClass("Model") then
		local updatedRecoilSpring = recoilspring:update(dt)

		camera:FindFirstChildOfClass("Model").PrimaryPart.CFrame *= CFrame.Angles(math.rad(updatedRecoilSpring.X) * 2, 0, 0)
		workspace.Camera.CFrame *= CFrame.Angles(math.rad(updatedRecoilSpring.X), math.rad(updatedRecoilSpring.Y), math.rad(updatedRecoilSpring.Z))
	end
	
	if char:FindFirstChildOfClass("Tool") then
		local tool = char:FindFirstChildOfClass("Tool")
		
		local itemstats = require(tool.Itemstats)
		
		if itemstats.generalstats.itemtype == "Ranged" and mousedownvalue == true and canfire == true and char.Humanoid:GetAttribute("Sprint") ~= true and tool.Values.Ammo.Value > 0 and reloading == false then
			canfire = false
			
			firebullet()
			
			recoilspring:shove(Vector3.new(1.5 * itemstats.weaponstats.hrecoilmod, math.random(-1, 1) * itemstats.weaponstats.hrecoilmod, math.random(1, 20) * itemstats.weaponstats.rotrecoilmod))
			
			task.wait(60/itemstats.weaponstats.rate)
			
			if itemstats.weaponstats.firetype == "Semi" then
				repeat task.wait() until mousedownvalue == false
				
				canfire = true
				
			elseif itemstats.weaponstats.firetype == "Auto" then
				canfire = true
			end
		end
	end
end)


As you can see, these all fire every frame.

This discussion should help ^

1 Like