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
01 | local Players = game:GetService( "Players" ) |
02 | local ReplicatedStorage = game:GetService( "ReplicatedStorage" ) |
03 | local ServerScriptService = game:GetService( "ServerScriptService" ) |
05 | local curWeaponsSystemFolder = script.Parent |
06 | local weaponsSystemFolder = ReplicatedStorage:FindFirstChild( "WeaponsSystem" ) |
07 | local weaponsSystemInitialized = false |
09 | local function initializeWeaponsSystemAssets() |
10 | if not weaponsSystemInitialized then |
12 | local effectsFolder = weaponsSystemFolder.Assets.Effects |
13 | local partNonZeroTransparencyValues = { |
14 | [ "BulletHole" ] = 1 , [ "Explosion" ] = 1 , [ "Pellet" ] = 1 , [ "Scorch" ] = 1 , |
15 | [ "Bullet" ] = 1 , [ "Plasma" ] = 1 , [ "Railgun" ] = 1 , |
17 | local decalNonZeroTransparencyValues = { [ "ScorchMark" ] = 0.25 } |
18 | local particleEmittersToDisable = { [ "Smoke" ] = true } |
19 | local imageLabelNonZeroTransparencyValues = { [ "Impact" ] = 0.25 } |
20 | for _, descendant in pairs (effectsFolder:GetDescendants()) do |
21 | if descendant:IsA( "BasePart" ) then |
(Local Script) name ClientWeaponScript
01 | local ReplicatedStorage = game:GetService( "ReplicatedStorage" ) |
03 | local playerChildAddedConnection |
04 | local replicatedStorageChildAddedConnection |
05 | local clientWeaponsScript |
06 | local weaponsSystemFolder |
08 | local function setupWeaponsSystem() |
09 | local WeaponsSystem = require(weaponsSystemFolder.WeaponsSystem) |
10 | if not WeaponsSystem.doingSetup and not WeaponsSystem.didSetup then |
15 | local function onReplicatedStorageChildAdded(child) |
16 | if child.Name = = "WeaponsSystem" then |
18 | replicatedStorageChildAddedConnection:Disconnect() |
22 | local function onPlayerChildAdded(child) |
23 | if child.Name = = "PlayerScripts" then |
24 | clientWeaponsScript.Parent = child |
25 | playerChildAddedConnection:Disconnect() |
(ModuleScript) name NewworkingCallbacks
01 | local RunService = game:GetService( "RunService" ) |
02 | local Players = game:GetService( "Players" ) |
04 | local IsServer = RunService:IsServer() |
05 | local LocalPlayer = ( not IsServer) and Players.LocalPlayer or nil |
07 | local NetworkingCallbacks = { } |
08 | NetworkingCallbacks.WeaponsSystem = nil |
10 | function NetworkingCallbacks.WeaponFired(player, instance, fireInfo) |
11 | local WeaponsSystem = NetworkingCallbacks.WeaponsSystem |
12 | if not WeaponsSystem then |
16 | local weapon = WeaponsSystem.getWeaponForInstance(instance) |
17 | local weaponType = getmetatable (weapon) |
19 | if weapon and weaponType then |
20 | if weapon.instance = = instance and weaponType.CanBeFired and weapon.player = = player then |
21 | weapon:onFired(player, fireInfo, true ) |
(ModuleScript) WeaponsSystem
01 | local CollectionService = game:GetService( "CollectionService" ) |
02 | local RunService = game:GetService( "RunService" ) |
03 | local Players = game:GetService( "Players" ) |
05 | local IsServer = RunService:IsServer() |
08 | local WeaponData = script.Parent:WaitForChild( "WeaponData" ) |
09 | local WeaponsSystemFolder = script.Parent |
10 | local WeaponTypes = WeaponsSystemFolder:WaitForChild( "WeaponTypes" ) |
11 | local Libraries = WeaponsSystemFolder:WaitForChild( "Libraries" ) |
12 | local ShoulderCamera = require(Libraries:WaitForChild( "ShoulderCamera" )) |
13 | local WeaponsGui = require(Libraries:WaitForChild( "WeaponsGui" )) |
14 | local SpringService = require(Libraries:WaitForChild( "SpringService" )) |
15 | local ancestorHasTag = require(Libraries:WaitForChild( "ancestorHasTag" )) |
16 | ShoulderCamera.SpringService = SpringService |
18 | local Configuration = WeaponsSystemFolder:WaitForChild( "Configuration" ) |
19 | local ConfigurationValues = { |
20 | SprintEnabled = Configuration:WaitForChild( "SprintEnabled" ), |
21 | SlowZoomWalkEnabled = Configuration:WaitForChild( "SlowZoomWalkEnabled" ), |
24 | local WEAPON_TAG = "WeaponsSystemWeapon" |
25 | local WEAPON_TYPES_LOOKUP = { } |
27 | local REMOTE_EVENT_NAMES = { |
30 | "WeaponReloadRequest" , |
32 | "WeaponReloadCanceled" , |
35 | local REMOTE_FUNCTION_NAMES = { } |
Script in ReplicatedStorage - folder WeaponTypes - BulletWeapon (Module Script)
01 | local TweenService = game:GetService( "TweenService" ) |
02 | local RunService = game:GetService( "RunService" ) |
03 | local Players = game:GetService( "Players" ) |
04 | local Debris = game:GetService( "Debris" ) |
05 | local ContextActionService = game:GetService( "ContextActionService" ) |
06 | local CollectionService = game:GetService( "CollectionService" ) |
07 | local ContentProvider = game:GetService( "ContentProvider" ) |
09 | local IsServer = RunService:IsServer() |
11 | local WeaponsSystemFolder = script.Parent.Parent |
12 | local Libraries = WeaponsSystemFolder:WaitForChild( "Libraries" ) |
13 | local BaseWeapon = require(Libraries:WaitForChild( "BaseWeapon" )) |
14 | local Parabola = require(Libraries:WaitForChild( "Parabola" )) |
15 | local Roblox = require(Libraries:WaitForChild( "Roblox" )) |
17 | local Effects = WeaponsSystemFolder:WaitForChild( "Assets" ):WaitForChild( "Effects" ) |
18 | local ShotsFolder = Effects:WaitForChild( "Shots" ) |
19 | local HitMarksFolder = Effects:WaitForChild( "HitMarks" ) |
20 | local CasingsFolder = Effects:WaitForChild( "Casings" ) |
22 | local NO_BULLET_DECALS = false |
23 | local NO_BULLET_CASINGS = false |