How can i create a system that allows the user to select the Gun, weapon etc?
my current script is:
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
local TweenService = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CameraPart1 = workspace:WaitForChild("ModCamera"):WaitForChild("Camera")
local CameraPart2 = workspace:WaitForChild("ModCamera"):WaitForChild("LeftCamera")
local CameraPart3 = workspace:WaitForChild("ModCamera"):WaitForChild("RightCamera")
local gun = require(ReplicatedStorage.Data.CurrentGun)
repeat wait() until Player.Character
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = CameraPart1.CFrame
script.Parent.Enabled = true
local function showArms()
Player.PlayerGui.HUD.Enabled = true
script.Parent.Enabled = false
Camera.CameraType = Enum.CameraType.Custom
--[[local gun = game.ReplicatedStorage.Guns.M1911:Clone()
local run = game:GetService("RunService")
gun.Parent = Camera]]
Player.PlayerScripts.FireClient.Disabled = false
--Player.CameraMode = Enum.CameraMode.LockFirstPerson]
_G.Camera = true
end
local StarterGui = game:GetService("StarterGui")
--[[StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
StarterGui:SetCore("TopbarEnabled", false)]]
local Arrows = script.Parent
local Left = Arrows.Left
local Right = Arrows.Right
local Play = Arrows.Bottom
local canPress = true
local left = {}
left.CFrame = CameraPart2.CFrame
local center = {}
center.CFrame = CameraPart1.CFrame
local right = {}
right.CFrame = CameraPart3.CFrame
local Time = TweenInfo.new(1.5)
Left:WaitForChild('Button').MouseButton1Click:Connect(function()
if canPress then
if Camera.CFrame == CameraPart1.CFrame then
canPress = false
local tween = TweenService:Create(Camera, Time, left)
tween:Play()
wait(1.5)
canPress = true
elseif Camera.CFrame == CameraPart3.CFrame then
canPress = false
local tween = TweenService:Create(Camera, Time, center)
tween:Play()
wait(1.5)
canPress = true
else
canPress = false
local tween = TweenService:Create(Camera, Time, right)
tween:Play()
wait(1.5)
canPress = true
end
end
end)
Right:WaitForChild('Button').MouseButton1Click:Connect(function()
if canPress then
if Camera.CFrame == CameraPart1.CFrame then
canPress = false
local tween = TweenService:Create(Camera, Time, right)
tween:Play()
gun.currentGun = "DEAGLE44"
wait(1.5)
canPress = true
elseif Camera.CFrame == CameraPart2.CFrame then
canPress = false
local tween = TweenService:Create(Camera, Time, center)
tween:Play()
gun.currentGun = "M1911"
wait(1.5)
canPress = true
else
canPress = false
local tween = TweenService:Create(Camera, Time, left)
tween:Play()
gun.currentGun = "AWM"
wait(1.5)
canPress = true
end
end
end)
Play:WaitForChild("Play").MouseButton1Click:Connect(function()
showArms()
end)
which i will rewrite once i get the time for it because it does not select the gun when i select with the client framework:
--// Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
--// Main Variables
local Player = Players.LocalPlayer
local Mouse = Player:GetMouse()
local currentGun = require(ReplicatedStorage.Data.CurrentGun)
Player.CharacterAdded:Connect(function(Character)
local function getGun()
local Gun = ReplicatedStorage.Weapons:FindFirstChild(currentGun.currentGun)
local Settings = require(ReplicatedStorage.Data[Gun.Name].Settings)
wait(5)
print(Gun.Name)
print(Settings.damage)
end
if currentGun.currentGun ~= "" then
getGun()
else
repeat wait() until not currentGun.currentGun == ""
getGun()
end
end)