Arm Cannon Issue

Hello, I’m new at scripting and I am attempting to make a fighting/fps game. Though I have encountered an issue with this arm cannon I’m making.

What I want to achieve: A fully functional arm cannon (like mega man’s)

The issue: When I shoot the arm cannon its projectiles bounces when they hit a part. And I want its projectiles to not fall or arc. I can increase the velocity of the part but I want the players to see the projectiles.

What I have tried so far: I have tried looking it up on the devforum and google yet couldn’t find anything.

My script for the movement of the projectile:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("ShotEvent")
local ServerStorage = game:GetService("ServerStorage")

remoteEvent.OnServerEvent:Connect(function(player, gunPos, mosPos)
	local bullet ="Part")
	bullet.Name = "Bullet"
	bullet.Parent = game.Workspace
	bullet.Shape = Enum.PartType.Ball
	bullet.Size =, 0.30, 0.8)
	bullet.BrickColor ="Teal")
	bullet.Material = ("Neon")
	local damageScript = ServerStorage:FindFirstChild("Damage"):Clone()
	damageScript.Parent = bullet
	local attacker ="StringValue")
	attacker.Name = "Attacker"
	attacker.Parent = bullet
	attacker.Value = player.Name

	local distance = (mosPos).magnitude
	local speed = 500
	bullet.CFrame =, mosPos)
	bullet.Velocity = bullet.CFrame.lookVector * speed

Thanks :smiley:

You could try raycasting. Usually when making a system like this I will shoot a ray from the gun, then return the part hit and destination position. Then simply tween the bullet from the players gun to the destination. You can easily get a straight line shot and allow the bullet to disappear and not bounce when it hits the target.

Alright. I’m not too familiar with ray casting. Do you know any tutorials or discussions that could help me? Thanks.

Below is a straight forward way to create a ray that shoots from the parts front face 50 studs forward.

-- Cast the ray
local part = workspace.Part
local raycastResult = workspace:Raycast(part.Position, part.CFrame.LookVector*50)

Then from raycastResult there are 4 parameters you can return like this:

    print("Object/terrain hit:", raycastResult.Instance:GetFullName())
    print("Hit position:", raycastResult.Position)
    print("Surface normal at the point of intersection:", raycastResult.Normal)
    print("Material hit:", raycastResult.Material.Name)

You want the raycastResult.Position to get the spot that the gun shot at.

Thank you so much! I will check out the article you posted.

1 Like

Alright I checked out the ray-casting thing. Though if I used ray casting wouldn’t it just shoot out a beam? Is there a way I could add a script where if my already made projectiles if they collide with something their transparency sets to 1 and you can’t collide with it? (Sorry If I sound dumb like I said, I’m new at this stuff)

You could try adding a .Touched event if you want to do it that way. But I would really recommend you using rays because that’s how 99.99% of shooter games do it. Also rays aren’t physical beams, its the act of sending out an invisible ray from a position in a specified direction with a defined length. And once cast, you can detect if the ray hits a part and the position that it hit.

Ok that makes sense… but I don’t know how to turn that into code…