Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

how would i make a gun customization system?

so i made an ak, with aiming (no shooting lol) and i wanted to make it so that you can add a red dot, a scope (why tho?) or even laser and barrel attachments. (camo might come soon idk). i made a viewport frame and then added a localscript. idk why it is not working

local viewport = script.Parent
local rs = game:GetService("ReplicatedStorage")
local cloneAk = rs.GunModels.AK47:Clone()
cloneAk.Parent = script.Parent

idk. i just like the gun customization in phantom forces so i wanted to replicated (storage)that. please help me.

1 answer

✓ Accepted answer

To fix your code, viewports need a camera for it to work. Then, set the camera's CFrame property to the viewmodel's head. Here's the fixed code!

local viewport = script.Parent
local rs = game:GetService("ReplicatedStorage")
local cloneAk = rs.GunModels.AK47:Clone()
local cam = Instance.new("Camera")

viewport.CurrentCamera = cam
cam.Parent = game.Workspace
cam.CFrame = cloneAk.Head.CFrame
cloneAk.Parent = script.Parent

For your question, you could add all the attachments and just disable their functions and/or make them invisible when they are not in use. Unfortunately I am not able to include the code, so you're going to have to figure it out. You're going to need to have knowledge of GUIs, RemoteEvents, and other things you'll need to accomplish this.

This discussion is preserved as it was. New answers, comments, and votes are closed.