Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Bullet rotated the wrong way (still shooting the right direction)?

I'm using the FastCast module, but the problem I am having is definitely not related to the module. Here is where I believe the problem is:

if Tool.Parent:IsA("Backpack") then return end 
	
	local directionalCF = CFrame.new(Vector3.new(), direction)
	local direction = (directionalCF * CFrame.fromOrientation(0, 0, RNG:NextNumber(0, TAU)) * 					CFrame.fromOrientation(math.rad(RNG:NextNumber(MIN_BULLET_SPREAD_ANGLE, MAX_BULLET_SPREAD_ANGLE)), 0, 0)).LookVector
	
	
	local humanoidRootPart = Tool.Parent:WaitForChild("HumanoidRootPart", 1)	-- Add a timeout to this.
	local myMovementSpeed = humanoidRootPart.Velocity							
	local modifiedBulletSpeed = (direction * BULLET_SPEED) + myMovementSpeed	-- We multiply our direction unit by the bullet speed. This creates a Vector3 version of the bullet's velocity at the given speed. We then add MyMovementSpeed to add our body's motion to the velocity.
	
	-- Prepare a new cosmetic bullet
	local bullet = CosmeticBullet:Clone()
	bullet.CFrame = CFrame.new(FirePointObject.WorldPosition, FirePointObject.WorldPosition + direction)
	bullet.Parent = workspace
	
--this is where it actually fires
	if PIERCE_DEMO then
		Caster:Fire(FirePointObject.WorldPosition, direction * BULLET_MAXDIST, modifiedBulletSpeed, bullet, Tool.Parent, false, BULLET_GRAVITY, CanRayPierce)
	else
		Caster:Fire(FirePointObject.WorldPosition, direction * BULLET_MAXDIST, modifiedBulletSpeed, bullet, Tool.Parent, false, BULLET_GRAVITY)
	end

The bullet fires in the right direction, but the bullet's rotation is always the wrong way. I already tried putting a script in the bullet that kept it always rotated the right way, but that didn't fix it.

1 answer

✓ Accepted answer

Make sure that your bullet's front side is actually the front direction (do this by checking the object's properties in "Surfaces"). When you get the "LookVector" it will rotate and direct your bullet towards that direction which probably means that that's the cause of your issue.

If you have any questions or issues contact me. ;)

2 comments

0

Yeah, that was the problem, thanks :). Do you know any easy ways to change the front direction of a part like a cylinder?

0

Just rotate it. Currently, if you're trying to change a surface direction I'm quite unsure. Roblox doesn't seem to have any documentation of this nor am able to find anything in reguards to this.

This discussion is preserved as it was. New answers, comments, and votes are closed.