How do i ADS a gun... please

So im triying to make a gun system, and you know, you can aim guns.
HOW DO I DO THAT?
i searched every forum post and all the answers dont work.
PEASE BLESS ME WITH YOUR KNOWLEDGE

also here’s my place file if you wanna look
GunTest.rbxl (357.2 KB)

and the script:

Script Code
local arms = script:WaitForChild("armsViewmodel")

arms.Parent = workspace.CurrentCamera

local run = game:GetService("RunService")

local AimOffset = CFrame.identity
arms.ChildAdded:Connect(function(child: Instance) 
	local hand = child:FindFirstChild("HandleV")
	if child.Name == "Model" and hand then
		arms["Right Arm"].RightGrip.Part1 = hand
		arms["Right Arm"].RightGrip.C0 = child:GetAttribute("Grip")
		offset = arms.HumanoidRootPart.CFrame:ToObjectSpace(arms.Model.Aim.CFrame:Inverse())
	end
end)
arms.ChildRemoved:Connect(function(child: Instance) 
	local hand = child:FindFirstChild("HandleV")
	if child.Name == "Model" and hand then
		arms["Right Arm"].RightGrip.Part1 = nil
	end
end)


local function DivideCFrame(CF:CFrame,ammount)
	local position = CF.Position
	local x,y,z = CF:ToOrientation()
	
	return CF.Rotation + (CF.Position / ammount)
end

local oldC1 = arms.HumanoidRootPart.Torso.C0
game.Players.LocalPlayer:GetMouse().Button2Down:Connect(function() 
	print(offset)
	arms.HumanoidRootPart.Torso.C0 = offset or CFrame.identity
end)
game.Players.LocalPlayer:GetMouse().Button2Up:Connect(function() 
	arms.HumanoidRootPart.Torso.C0 = oldC1
end)
run.RenderStepped:Connect(function(deltaTime: number) 
	
	
	arms:PivotTo(game.Players.LocalPlayer.Character.Head.CFrame)
	for _,v in arms:GetChildren() do
		if v:IsA("BasePart") then
			v.CanCollide = false
			v.CanQuery = false
			v.CanTouch = false
		end
	end
end)
3 Likes

so what ur gonna wanna do is steal the laser tag code and make it give damage

1 Like

Have you tried making an aim part weld it to the gun then when they do your aim input you set the camera to that parts CFrame?

1 Like

I saw your baseplate and I definitely have some things to say, but first how do you develop bro :sob:? The aim attachment is pretty bad located, your script viewmodel’s humanoidrootpart isn’t well positioned, Why did you make a lerp function (DivideCFrame)? just use Cframe:Lerp(), and I’d like to say more thing, but there are a lot of things, so I’ll pass you your baseplate with some modifications and the ADS, I made it as FPS games does
GunTestModificated.rbxl (357,1 KB)
.

When you equip the nagant, the script gets nagant model’s aim attachment WorldCFrame and uses it for calculating the AimOffset.

I made some other changes but you’ll see them in the baseplate, I’d recommend you to analize it and I think you should do another thing instead of a gun system as it could be complicated for beginners and definitely there are a lot of things that you need to learn yet.

2 Likes

sory this is an old post i forgot to delete it : P

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.