Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how would i make a gun customization system?

Asked by 2 years ago

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

Log in to vote
0
Answered by
Neatwyy 123
2 years ago

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.

Ad

Answer this question