Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Fix -Roblox Dev , Weapons Kit - Tool / gun works in Studio, but when pub it does not fire?

Asked by 4 years ago

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


01local Players = game:GetService("Players")
02local ReplicatedStorage = game:GetService("ReplicatedStorage")
03local ServerScriptService = game:GetService("ServerScriptService")
04 
05local curWeaponsSystemFolder = script.Parent
06local weaponsSystemFolder = ReplicatedStorage:FindFirstChild("WeaponsSystem")
07local weaponsSystemInitialized = false
08 
09local function initializeWeaponsSystemAssets()
10    if not weaponsSystemInitialized then
11        -- Enable/make visible all necessary assets
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,
View all 21 lines...

(Local Script) name ClientWeaponScript


01local ReplicatedStorage = game:GetService("ReplicatedStorage")
02 
03local playerChildAddedConnection
04local replicatedStorageChildAddedConnection
05local clientWeaponsScript
06local weaponsSystemFolder
07 
08local function setupWeaponsSystem()
09    local WeaponsSystem = require(weaponsSystemFolder.WeaponsSystem)
10    if not WeaponsSystem.doingSetup and not WeaponsSystem.didSetup then
11        WeaponsSystem.setup()
12    end
13end
14 
15local function onReplicatedStorageChildAdded(child)
View all 27 lines...

(ModuleScript) name NewworkingCallbacks


01local RunService = game:GetService("RunService")
02local Players = game:GetService("Players")
03 
04local IsServer = RunService:IsServer()
05local LocalPlayer = (not IsServer) and Players.LocalPlayer or nil
06 
07local NetworkingCallbacks = {}
08NetworkingCallbacks.WeaponsSystem = nil
09 
10function NetworkingCallbacks.WeaponFired(player, instance, fireInfo)
11    local WeaponsSystem = NetworkingCallbacks.WeaponsSystem
12    if not WeaponsSystem then
13        return
14    end
15 
View all 24 lines...

(ModuleScript) WeaponsSystem


01local CollectionService = game:GetService("CollectionService")
02local RunService = game:GetService("RunService")
03local Players = game:GetService("Players")
04 
05local IsServer = RunService:IsServer()
06 
07-- Dependencies
08local WeaponData = script.Parent:WaitForChild("WeaponData")
09local WeaponsSystemFolder = script.Parent
10local WeaponTypes = WeaponsSystemFolder:WaitForChild("WeaponTypes")
11local Libraries = WeaponsSystemFolder:WaitForChild("Libraries")
12local ShoulderCamera = require(Libraries:WaitForChild("ShoulderCamera"))
13local WeaponsGui = require(Libraries:WaitForChild("WeaponsGui"))
14local SpringService = require(Libraries:WaitForChild("SpringService"))
15local ancestorHasTag = require(Libraries:WaitForChild("ancestorHasTag"))
View all 35 lines...

Script in ReplicatedStorage - folder WeaponTypes - BulletWeapon (Module Script)

01local TweenService = game:GetService("TweenService")
02local RunService = game:GetService("RunService")
03local Players = game:GetService("Players")
04local Debris = game:GetService("Debris")
05local ContextActionService = game:GetService("ContextActionService")
06local CollectionService = game:GetService("CollectionService")
07local ContentProvider = game:GetService("ContentProvider")
08 
09local IsServer = RunService:IsServer()
10 
11local WeaponsSystemFolder = script.Parent.Parent
12local Libraries = WeaponsSystemFolder:WaitForChild("Libraries")
13local BaseWeapon = require(Libraries:WaitForChild("BaseWeapon"))
14local Parabola = require(Libraries:WaitForChild("Parabola"))
15local Roblox = require(Libraries:WaitForChild("Roblox"))
View all 23 lines...
0
Hello.... Lord_BradyRocks -5 — 4y

Answer this question