hey! im kuroheights and this is my first post, today ill be showing you how to create a viewmodel gun system (my way ofc but you can obviously modify it to your liking) THIS WILL BE CONFIGURABLE WITH SETTINGS
step 1. getting the viewmodel
first you need to find a compatible viewmodel that is properly jointed, i would recommend this one: https://create.roblox.com/marketplace/asset/6725281710?viewFromStudio=true&keyword=viewmodel&searchId=D801F06C-9122-47C7-B66E-DA912B38FF5A
after you have your viewmodel, your gonna wanna create a folder in replicated storage named Framework, this is where you will have your scripts and stuff under.
step 2: actually making the script for VM and stuff
make a folder under framework named Viewmodels, then put your viewmodel in that.
this is what you should have so far:
now that you have everything setup, lets move onto the equip.
create a local script in startergui and name it whatever you want, your gonna wanna keep this since its the script and settings
well, heres the script, modify it to your liking. unfortunately rblx dev fourm wont allow my indents so sorry!
SCRIPT, IMPORTANT
local rs = game.ReplicatedStorage
local framework = rs.Framework
local vms = framework.Viewmodels
—settings
local vm = vms.Gun — vms.YOURVMNAMEHERE
—vm stuff
local plr = game:GetService(“Players”).LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local mouse = plr:GetMouse() — will be used for click detection and stuff
local run = game:GetService(“RunService”)
local uis = game:GetService(“UserInputService”)
local cam = workspace.CurrentCamera
local ofcam = CFrame.new(0,0,0)
local equipped = false
local function vmpos()
vm.PrimaryPart:PivotTo(cam.CFrame*ofcam)
end
—equip thing, since im feeling nice
uis.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.One then
if equipped == false then
vm.Parent = cam
equipped = true
return
end
if equipped == true then
vm.Parent = vms
equipped = false
return
end
end
end)
run.RenderStepped:Connect(vmpos)
thats the end of this for now, this will let your vm appear and if you press 1 it will equip.
let me know if you want me to finish this by liking or replying, i dont really know (5 likes and ill continue this, featuring a fire, reload, and maybe more)
hey, i know i havent updated this yet, im currently working on a couple projects and a bit busy, will do this in my free time next chance i get
EDIT: I HAVE CHANGED vm:SetPrimaryPartCFrame TO vm.PrimaryPart:PivotTo AS IT NEWER AND WILL NOT BE REMOVED FOR A WHILE