I am making an FPS but i don't know how to allow for aiming down sights. The current code i have might help
local camera = workspace.CurrentCamera
local RS = game:GetService("RunService")
local voffset = CFrame.new(0,-1,0)
--// Weapon Varibles \\--
local equipped = nil
local root = nil
local viewport = nil
local module = nil
local previousEquipped = nil
local function setweapon(weaponname)
if viewport ~= nil and root ~= nil then
viewport.Parent = root.Model
end
equipped = weaponname
root = game.ReplicatedStorage.Guns:WaitForChild(equipped)
viewport = root.Model:FindFirstChildWhichIsA("Model")
module = require(root.Module:FindFirstChildWhichIsA("ModuleScript"))
viewport.Parent = workspace
end
setweapon("Glock")
previousEquipped = equipped
RS.RenderStepped:Connect(function()
viewport:SetPrimaryPartCFrame(camera.CFrame * voffset)
if not previousEquipped == equipped then
setweapon(equipped)
end
end)
game:GetService("UserInputService").InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Two then
voffset:Lerp()
end
end)
Can anyone help me?
Edit: Look in the first answer. that is where i will put updates.

1 comment
You gotta try it out yourself bud, if it doesn't work out then you can come here ask what gone wrong