Bullet shells get ejected in slow motion


i’m making a viewmodel thing and the bullets sometimes get ejected in slow motion. it doesn’t happen when they’re un-cancollided or have no rotvelocity

local bullet = repStorage.Bullet:Clone()
		bullet.Parent = workspace
		bullet.CFrame = currentWeaponViewmodel.Gun.Slide.CFrame * CFrame.Angles(0,math.rad(180),0)
		bullet.Velocity = bullet.CFrame.RightVector * 15 + Vector3.new(0,10,0)
		bullet.RotVelocity = Vector3.new(math.random(-10,10),math.random(-10,10),math.random(-10,10))
		game:GetService("Debris"):AddItem(bullet,5)
1 Like

You are using an outdated physics engine…
Instead use :ApplyImpulse and :ApplyAngularVelocity methods
or use that
image

He is using that for bullet cases falling out of gun…
:man_facepalming:

1 Like

so ig that just decreased the chance of it happening? i originally marked this as the solution because after like 6 times of testing it, it worked fine, but now it’s starting to happen again just at random

local bullet = repStorage.Bullet:Clone()
		bullet.Parent = workspace
		bullet.CFrame = viewmodel.Gun.Slide.CFrame * CFrame.Angles(0,math.rad(180),0)
		bullet.AssemblyLinearVelocity = bullet.CFrame.RightVector * 15 + Vector3.new(0,10,0)
		bullet.AssemblyAngularVelocity = Vector3.new(math.random(-10,10),math.random(-10,10),math.random(-10,10))
		
		while wait(.1) do --(this is here to make the bullet stop moving when it hits the ground)
			local part = workspace:FindPartOnRay(Ray.new(bullet.Position,Vector3.new(0,-.075,0)),bullet)
			if part then
				bullet.Anchored = true
				bullet.CanCollide = false
				wait(10)
				bullet:Destroy()
				break
			end
		end
1 Like

wait() is depracated…
DUDE WTF :skull:
Everything you use is literally depracated :skull:

1 Like

image
thank you for calling something random deprecated rather than helping me further

2 Likes

Click on this methods below i sent you modern alternative to them
FindPartOnRay,wait,Ray?,Vector3 (partically), also you could replace it with Debris anyways…

Use task.wait() instead of wait(), wait() throttles. This issue might be based on your fps, try with a high framerate and low framerate. If it is, you need to take account for delta time which you can retrieve by either using task.wait() or RunService.Heartbeat:Wait().

1 Like

My theory is that it may be occurring due to too many physics objects being created. Perhaps introducing a queue of sorts to keep track of how many were created would help? You could also use that collision group thing to prevent the shells from merging with the gun, which seems to be what your code’s attempting to accomplish.

3 Likes

Doubt it, the amount he’s shooting shouldn’t lag out the game, if it did that’d be very concerning for a lot of other games.

Gun has collisions already disabled likely and Debris | Documentation - Roblox Creator Hub would be more than enough

Eh that’s true. It was a suggestion based off of an observation I had made and concluded that Roblox’s physics as of late seem to be kind of shoddy.

1 Like

the collision thing worked even though the gun already has no collision

1 Like

Isn’t Debris also “deprecated”/unadvised to use somewhat?

maybe it’s the orange flash it’s colliding with? did you make sure that didn’t have collisions?

3 Likes

yeah it has no collision either
it kind of makes sense why the collision group worked since when the bullet just flat out had no collision and fell through the map, it worked fine. i only started having the slow-mo issue when i enabled cancollide

1 Like

Source?
No source? Baseless claim
Lmao even chat gpt says that its not depracated

That’s just what I was thinking as well. It’s subject to the same throttling issue as wait() and has a high max item queue.

Personally I believe that wait(n) is fine unless you’re depending on constant precision and consistency in your program. If it’s not needed, then using wait(n) here or there is a non-issue.

3 Likes

didn’t mean deprecated in the literal sense, it was because you said wait() and vector3 were deprecated (which I’m assuming you mean not advised to use)

as said above it’s subject to a throttling issue like wait(), and fwik there’s no better alternative that isn’t user-created

no comment

They kinda is depracated tho

What is wrong using chat gpt as a search engine?
“Ah yes lets frame every chat gpt user as vibe coder” mindset.
Too bad this mindset is called egoism

Actually now that I think about it, you could change how that works. You could utilize the collision group to have the bullet not interact with the player character / gun, and then use Touched for when it touches the ground, completely eliminating having to utilize a loop.

local tconn = nil
tconn = bullet.Touched:Connect(function()
	if tconn.Connected == false then
		return
	end
	local part, pos = Workspace:FindPartOnRay(Ray.new(bullet.Position, Vector3.new(0, -2, 0)), bullet)
	if part ~= nil and (bullet.Position - pos).Magnitude <= 0.75 then
		tconn:Disconnect()
		Debris:AddItem(bullet, 10)
		bullet.Anchored = true
		bullet.CanCollide = false
	end
end)
1 Like