local Players = game:GetService("Players")
local PLAYER = Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local fldr_MODULES = ReplicatedStorage:FindFirstChild("Modules")
local FRAMEWORK = require(fldr_MODULES:FindFirstChild("Framework"))
local fldr_WEAPONS = ReplicatedStorage:FindFirstChild("Weapons")
local fldr_VIEWMODELS = ReplicatedStorage:FindFirstChild("Viewmodels")
local obj_ARMS = fldr_VIEWMODELS:FindFirstChild("Arms")
local fldr_SKINS = ReplicatedStorage:FindFirstChild("Skins")
w_CAMERA = workspace.CurrentCamera
local inv_DEFAULT = FRAMEWORK.inv_DEFAULT
local cur_WEAPON = FRAMEWORK.cur_WEAPON
local cur_VIEWMODEL = FRAMEWORK.cur_VIEWMODEL
local cur_SKIN = FRAMEWORK.cur_SKIN
local uit_GAMEPAD = {
Enum.UserInputType.Gamepad1,
Enum.UserInputType.Gamepad2,
Enum.UserInputType.Gamepad3,
Enum.UserInputType.Gamepad4,
Enum.UserInputType.Gamepad5,
Enum.UserInputType.Gamepad6,
Enum.UserInputType.Gamepad7,
Enum.UserInputType.Gamepad8,
};
function GetGamepad()
for i, v in ipairs(uit_GAMEPAD) do
if UserInputService:GetGamepadConnected(v) then
return v
end
end return nil -- No gamepad types found
end
UserInputService.InputBegan:Connect(function(INPUT)
if INPUT.UserInputType == Enum.UserInputType.Keyboard then -- PC/Computer/Keyboard
if INPUT.KeyCode == Enum.KeyCode.One then -- Primary
cur_WEAPON = inv_DEFAULT[1] -- Index the current inventory for the primary (first weapon)
FRAMEWORK:Equip(cur_VIEWMODEL) -- Called to ensure the viewmodel equipped is correct
elseif INPUT.KeyCode == Enum.KeyCode.Two then -- Secondary
cur_WEAPON = inv_DEFAULT[2] -- Index the current inventory for the secondary (second weapon)
FRAMEWORK:Equip(cur_VIEWMODEL)
elseif INPUT.KeyCode == Enum.KeyCode.Three then -- Melee
cur_WEAPON = inv_DEFAULT[3] -- Index the current inventory for the melee (third weapon)
FRAMEWORK:Equip(cur_VIEWMODEL)
elseif INPUT.KeyCode == Enum.KeyCode.Q then
-- SWITCH TO LAST WEAPON BEFORE CURRENT (function)
end
elseif INPUT.UserInputType == Enum.UserInputType.Touch then -- Mobile
-- code for weapons here
elseif INPUT.UserInputType == GetGamepad() then
-- Console/controller player
end
end)
RunService.RenderStepped:Connect(function(DT)
FRAMEWORK:Update(cur_VIEWMODEL, DT)
end)
To embed this project on your website, copy the following code and paste it into your website's HTML: