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

Setting a projectile's rotation?

Hi, I'm trying to create a gun that fires cylinder-shaped projectiles. I want the projectiles to be rotated in a way that the ends are facing downwards and not side to side.

player = game.Players.LocalPlayer
weapon = script.Parent
mouse = player:GetMouse()
function shoot()
	local laser = Instance.new("Part", workspace)
	laser.Shape = "Cylinder"
	laser.CanCollide = false
	laser.Size = Vector3.new()
	laser.BottomSurface = "Smooth"
	laser.BackSurface = "Smooth"
	laser.FrontSurface = "Smooth"
	laser.LeftSurface = "Smooth"
	laser.RightSurface = "Smooth"
	laser.TopSurface = "Smooth"
	laser.Rotation = Vector3.new( 0, 0, 90)
	laser.CFrame = weapon.Handle.CFrame
	laser.CFrame = CFrame.new(laser.Position,mouse.Hit.p)
	v = Instance.new("BodyVelocity", laser)
	v.Velocity = laser.CFrame.lookVector *90
	v.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
end
weapon.Activated:connect(shoot)

Even though I set the projectile's rotation, the rotation is still way off when it's fired.

1 comment

0

CFrame is Position and rotation. Try moving line 15 below line 17.

1 answer

Sorry for not explaining much, I am on my pad but maybe use CFrame.Angles(). Look it up, hope it helps.

1 comment

0

P-put a link on that topic!!!

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