here is the script of the gun that shoots the bullet

--locals
local mouse = game.Players.LocalPlayer:GetMouse()
local plr  = game.Players.LocalPlayer
local myhum = game.Workspace:WaitForChild(plr.Name).Humanoid
local config = script.Parent.Parent:WaitForChild("Config")
local debounce = true
local tool = script.Parent.Parent
local BaseShot = Instance.new("Part")
--creating bullet
BaseShot.Name = "Effect"
BaseShot.BrickColor = BrickColor.new("Black")
BaseShot.Material = Enum.Material.Neon
BaseShot.Shape = Enum.PartType.Block
BaseShot.TopSurface = Enum.SurfaceType.Smooth
BaseShot.BottomSurface = Enum.SurfaceType.Smooth
BaseShot.FormFactor = Enum.FormFactor.Custom
BaseShot.Size = Vector3.new(0.1, 0.1, 3)
BaseShot.CanCollide = false
BaseShot.Locked = true
BaseShot.Parent = game.ServerStorage
--main script
script.Parent.Parent.Activated:Connect(function()
	local barrelCFrame = script.Parent.Parent.barrel.CFrame
	local FiringPoint = barrelCFrame.p + barrelCFrame:VectorToWorldSpace(Vector3.new(0,0.4,-1.1))
	local ShotCFrame = CFrame.new(FiringPoint,mouse.Hit.p)
	
	local bulletclone = BaseShot:Clone()
	bulletclone.Parent = game.Workspace
	bulletclone.CFrame = barrelCFrame + (barrelCFrame.lookVector * (BaseShot.Size.Z / 2))
	local bodyv = Instance.new("BodyVelocity")
	bodyv.velocity = barrelCFrame.lookVector * 100
	bodyv.Parent = bulletclone
end)

nvm guys i did it thx a lot... here is the last part the main script:

script.Parent.Parent.Activated:Connect(function()
	local barrelCFrame = script.Parent.Parent.barrel.CFrame
	local FiringPoint = barrelCFrame.p + barrelCFrame:VectorToWorldSpace(Vector3.new(0,0.4,1.1))
	local ShotCFrame = CFrame.new(FiringPoint,mouse.Hit.p)
	
	local bulletclone = BaseShot:Clone()
	bulletclone.Parent = game.Workspace
	bulletclone.CFrame = ShotCFrame + (ShotCFrame.lookVector * (BaseShot.Size.Z / 2))
	local bodyv = Instance.new("BodyVelocity")
	bodyv.velocity = ShotCFrame.lookVector * 1000
	bodyv.Parent = bulletclone
end)

2 comments

0

try using a - on the BaseShot.Size.Z

0

i already solved it the last script replaces the main script