Hi,
I have a tool / gun that works fine in Studio, but when I publish it and play, it shows up in back pack and gets equipped (which is good), but when I left mouse click , it does not kick off the code that would make it fire. And there are no errors in Admin client or server.
(Note the source code and stuff is all from Roblox Dev site, the Weapons Kit, which when you bring it in, is full of warnings (issues) in the scripts, which I fixed I think, and then made the parts to have weld constraints and are unachored , and fixed grips ..just fyi , so I am trying to fix their tutorial example)
Things I have seen on web or people said from other posts related to this people did
"You have a ServerScript (ClassName Script) underneath the Tool which is in ReplicatedStorage. This is not best practice, and could have some potential issues as ServerScripts cannot run everywhere (and I think some fairly recent AntiExploit measures limited this scope even further with how closed source third party modules were injecting backdoors). Please look into moving the ServerScript into ServerScriptService, adjusting how the Tool interacts with it ClientSide and see if this helps "
if so above, which scripts where?
or
" the script that fires the bullet on the top add a
tool.OnEquipped do " um where or more details....
If anyone wants to look at it also via a teamcreate share, let me know (send be R friend invite) , code is below
Note I added these line in one of the scipts below.. maybe not right, but got past warnings..
-- ADDED these three below or warnings will happen, maybe wrong ? WeaponsSystem.camera = nil WeaponsSystem.gui = nil WeaponsSystem.StarterGui = nil
Things I do see in output when in studio are
ReplicatedStorage.WeaponsSystem is now active. ReplicatedStorage.WeaponsSystem is now active. (x2)
13:27:11.336 - ActivateCameraController did not select a module. (x2)
Which should it NOT be doing this three times? ReplicatedStorage.WeaponsSystem is now active.
Note the source of it came from https://developer.roblox.com/en-us/articles/weapons-kit
Scripts are in ReplicatedStorage
(Local Script) name ClientWeaponScript
(Script) named ServerWeaponScript
(ModuleScript) name NewworkingCallbacks
(ModuleScript) WeaponsSystem
Script in ReplicatedStorage - folder WeaponTypes - BulletWeapon (Module Script)
Because of the 10,000 char limit I cannot post the of the code scripts....but here is some of it
(Script) named ServerWeaponScript
local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage") local ServerScriptService = game:GetService("ServerScriptService") local curWeaponsSystemFolder = script.Parent local weaponsSystemFolder = ReplicatedStorage:FindFirstChild("WeaponsSystem") local weaponsSystemInitialized = false local function initializeWeaponsSystemAssets() if not weaponsSystemInitialized then -- Enable/make visible all necessary assets local effectsFolder = weaponsSystemFolder.Assets.Effects local partNonZeroTransparencyValues = { ["BulletHole"] = 1, ["Explosion"] = 1, ["Pellet"] = 1, ["Scorch"] = 1, ["Bullet"] = 1, ["Plasma"] = 1, ["Railgun"] = 1, } local decalNonZeroTransparencyValues = { ["ScorchMark"] = 0.25 } local particleEmittersToDisable = { ["Smoke"] = true } local imageLabelNonZeroTransparencyValues = { ["Impact"] = 0.25 } for _, descendant in pairs(effectsFolder:GetDescendants()) do if descendant:IsA("BasePart") then
(Local Script) name ClientWeaponScript
local ReplicatedStorage = game:GetService("ReplicatedStorage") local playerChildAddedConnection local replicatedStorageChildAddedConnection local clientWeaponsScript local weaponsSystemFolder local function setupWeaponsSystem() local WeaponsSystem = require(weaponsSystemFolder.WeaponsSystem) if not WeaponsSystem.doingSetup and not WeaponsSystem.didSetup then WeaponsSystem.setup() end end local function onReplicatedStorageChildAdded(child) if child.Name == "WeaponsSystem" then setupWeaponsSystem() replicatedStorageChildAddedConnection:Disconnect() end end local function onPlayerChildAdded(child) if child.Name == "PlayerScripts" then clientWeaponsScript.Parent = child playerChildAddedConnection:Disconnect() end end
(ModuleScript) name NewworkingCallbacks
local RunService = game:GetService("RunService") local Players = game:GetService("Players") local IsServer = RunService:IsServer() local LocalPlayer = (not IsServer) and Players.LocalPlayer or nil local NetworkingCallbacks = {} NetworkingCallbacks.WeaponsSystem = nil function NetworkingCallbacks.WeaponFired(player, instance, fireInfo) local WeaponsSystem = NetworkingCallbacks.WeaponsSystem if not WeaponsSystem then return end local weapon = WeaponsSystem.getWeaponForInstance(instance) local weaponType = getmetatable(weapon) if weapon and weaponType then if weapon.instance == instance and weaponType.CanBeFired and weapon.player == player then weapon:onFired(player, fireInfo, true) end end end
(ModuleScript) WeaponsSystem
local CollectionService = game:GetService("CollectionService") local RunService = game:GetService("RunService") local Players = game:GetService("Players") local IsServer = RunService:IsServer() -- Dependencies local WeaponData = script.Parent:WaitForChild("WeaponData") local WeaponsSystemFolder = script.Parent local WeaponTypes = WeaponsSystemFolder:WaitForChild("WeaponTypes") local Libraries = WeaponsSystemFolder:WaitForChild("Libraries") local ShoulderCamera = require(Libraries:WaitForChild("ShoulderCamera")) local WeaponsGui = require(Libraries:WaitForChild("WeaponsGui")) local SpringService = require(Libraries:WaitForChild("SpringService")) local ancestorHasTag = require(Libraries:WaitForChild("ancestorHasTag")) ShoulderCamera.SpringService = SpringService local Configuration = WeaponsSystemFolder:WaitForChild("Configuration") local ConfigurationValues = { SprintEnabled = Configuration:WaitForChild("SprintEnabled"), SlowZoomWalkEnabled = Configuration:WaitForChild("SlowZoomWalkEnabled"), } local WEAPON_TAG = "WeaponsSystemWeapon" local WEAPON_TYPES_LOOKUP = {} local REMOTE_EVENT_NAMES = { "WeaponFired", "WeaponHit", "WeaponReloadRequest", "WeaponReloaded", "WeaponReloadCanceled", "WeaponActivated" } local REMOTE_FUNCTION_NAMES = {}
Script in ReplicatedStorage - folder WeaponTypes - BulletWeapon (Module Script)
local TweenService = game:GetService("TweenService") local RunService = game:GetService("RunService") local Players = game:GetService("Players") local Debris = game:GetService("Debris") local ContextActionService = game:GetService("ContextActionService") local CollectionService = game:GetService("CollectionService") local ContentProvider = game:GetService("ContentProvider") local IsServer = RunService:IsServer() local WeaponsSystemFolder = script.Parent.Parent local Libraries = WeaponsSystemFolder:WaitForChild("Libraries") local BaseWeapon = require(Libraries:WaitForChild("BaseWeapon")) local Parabola = require(Libraries:WaitForChild("Parabola")) local Roblox = require(Libraries:WaitForChild("Roblox")) local Effects = WeaponsSystemFolder:WaitForChild("Assets"):WaitForChild("Effects") local ShotsFolder = Effects:WaitForChild("Shots") local HitMarksFolder = Effects:WaitForChild("HitMarks") local CasingsFolder = Effects:WaitForChild("Casings") local NO_BULLET_DECALS = false local NO_BULLET_CASINGS = false