--[[
    'Handle' - weapon fps offset
    'Right' & 'Left' - viewmodel placements
    'Body' - Main welding point
    
    Viewmodel attatched to a camera
--]]


-- Camera setup
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")

local Camera = workspace.CurrentCamera
local Humanoid = Players.LocalPlayer.CharacterAdded:Wait():WaitForChild("Humanoid")

local ViewmodelFolder = ReplicatedStorage.ViewmodelFolder
local Viewmodel = ViewmodelFolder:WaitForChild("Viewmodel"):Clone()

local function OnDeath()
    Viewmodel.Parent = nil
end

local function Update(dt)
    Viewmodel.Head.CFrame = Camera.CFrame
end

Humanoid.Died:Connect(OnDeath)
RunService.RenderStepped:Connect(Update)

-- Weapon stuff
local WeaponsFolder = ReplicatedStorage.WeaponsFolder
local Weapon = WeaponsFolder:WaitForChild("G-18"):Clone()

Weapon.Parent = Viewmodel
Viewmodel.Parent = Camera

local Joint = Instance.new("Motor6D")
Joint.C0 = CFrame.new(1, -1.5, -2) -- mess around with until it fits
Joint.Part0 = Viewmodel.Head
Joint.Part1 = Weapon.Handle
Joint.Parent = Viewmodel.Head

-- more coming soon

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: