Hi, I am creating a new game and for the weapons I am using Roblox Weapons Kit.
For lobby screen I am using a Scriptable camera type with the camera set to a part position. The problem is when I player spawns it changes the camera for all players even when they don’t have any weapons equipped (I am giving a weapon to player on spawn).
I have looked at the weapon system scripts but cannot seem to find the problem. Also I looked on the forums and didn’t find any topic with the similar problem. Hope someone can help me or point me in a direction of where should I look for the cause of the problem.
Also here is a video of a problem occurring:
EDIT: I fixed the camera problem with loading the character after player joins the game but the crosshair still shows up on the screen
No, just the one that’s getting in the game. Here is the full script from where it’s called.
-- services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ReplicatedFirst = game:GetService("ReplicatedFirst")
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local WeaponsFolder = ReplicatedStorage.Weapons
local Object = require(ReplicatedStorage.Objects.Object)
local Config = require(ReplicatedStorage.Config)
local require = require(ReplicatedStorage.Nevermore)
local Maid = require("Maid")
local UnequpiAllToolsEvent = ReplicatedStorage.Remotes.UnequipAllTools
local EquipToolEvent = ReplicatedStorage.Remotes.EquipTool
local GetWeaponAndShipDataFunction = ReplicatedStorage.Remotes.GetWeaponAndShipData
local weaponTable = {
[1] = "Unarmed";
[2] = "Primary";
[3] = "Secondary";
[4] = "Tertiary";
}
local WeaponSelectController = Object:extend()
function WeaponSelectController:init(frame)
self.maid = Maid.new()
self.button = frame.ImageButton
self.selectedWeapon = 1
self.running = true
end
function WeaponSelectController:Start()
self.running = true
local owned, equipped = GetWeaponAndShipDataFunction:InvokeServer()
self.weapons = {
Primary = equipped["Primary"] ~= "" and WeaponsFolder[equipped["Primary"]] or nil;
Secondary = equipped["Secondary"] ~= "" and WeaponsFolder[equipped["Secondary"]] or nil;
Tertiary = equipped["Gamepasses"] ~= "" and WeaponsFolder[equipped["Gamepasses"]] or nil;
}
self.maid:GiveTask(
self.button.Activated:Connect(function()
self:ChangeWeapon("Next")
end)
)
self:ChangeWeapon("Primary")
end
function WeaponSelectController:Stop()
self.running = true
if self.maid then self.maid:DoCleaning() end
end
function WeaponSelectController:ChangeWeapon(position)
if not self.running then return end
UnequpiAllToolsEvent:FireServer()
local weaponType = nil
if position == "Next" then
weaponType = weaponTable[self.selectedWeapon + 1 <= #weaponTable and self.selectedWeapon + 1 or 0]
else
weaponType = position
end
if self.weapons[weaponType] then
local weapon = self.weapons[weaponType]
EquipToolEvent:FireServer(weapon)
self.selectedWeapon = table.find(weaponTable, weaponType)
self.button.WeaponImage.Image = Config.Assets.Gui.HUD.WeaponSelect.WeaponImages[weapon.Name]
self.button.WeaponName.Text = weapon.Name
self.button.WeaponType.Text = string.upper(weaponTable[self.selectedWeapon]).." WEAPON"
elseif position == "Next" and weaponType ~= "Unarmed" then
self.selectedWeapon = self.selectedWeapon + 1 <= #weaponTable and self.selectedWeapon + 1 or 0
self:ChangeWeapon("Next")
elseif table.find(weaponTable, weaponType) then
self.selectedWeapon = table.find(weaponTable, weaponType)
self.button.WeaponImage.Image = Config.Assets.Gui.HUD.WeaponSelect.WeaponImages.Unarmed
self.button.WeaponName.Text = weaponTable[self.selectedWeapon]..(self.selectedWeapon ~= 0 and " WEAPON" or "")
self.button.WeaponType.Text = "WEAPON SELECTOR"
end
end
return WeaponSelectController