So whenever I clone a tool into a players backpack it doesn’t work (server script too)
but when I put it in the starterpack it works, Why does this happen?
Might not be this, but whenever a player spawns a new Backpack object is created and parented to them. The starterpack automatically detects when a new Backpack object is put into the Player, and clones the tools in itself into the player Backpack.
To adjust for this, you could wait for the new Backpack object to be placed into the player before you clone tools into their backpack.
This is the code:
for a,b in pairs(game.Players:GetChildren()) do
local randweapons = math.random(1, #weapons)
local loadout = weapons[randweapons]:Clone()
loadout.Parent = b.Backpack
end
end
Are the players spawned in yet when your code runs? You can check for this by checking if the Player.Character is nil, or by using the CharacterAdded and CharacterRemoved events.
Yeah it checks the player spawns
Interesting. And are the tools just not getting added into the backpacks at all? Any errors in the output?
The tools get added and theres no errors, its just the tool doesn’t work
Oh. Could you show the tool script(s)?
add the tool in the players StarterGear as well
The issue right now is that the tools aren’t working, not that the tools aren’t getting added into the backpack
I’m using the fe gun kit so this is the server script:
local Tool = script.Parent
local Handle = Tool:WaitForChild(“Handle”)
–local Player
–local Character
–local Humanoid
local Module = require(Tool:WaitForChild(“Setting”))
local ChangeMagAndAmmo = script:WaitForChild(“ChangeMagAndAmmo”)
local Grip2
local Handle2
if Module.DualEnabled then
Handle2 = Tool:WaitForChild(“Handle2”,1)
if Handle2 == nil and Module.DualEnabled then error("“Dual” setting is enabled but “Handle2” is missing!") end
end
local MagValue = script:FindFirstChild(“Mag”) or Instance.new(“NumberValue”,script)
MagValue.Name = “Mag”
MagValue.Value = Module.AmmoPerMag
local AmmoValue = script:FindFirstChild(“Ammo”) or Instance.new(“NumberValue”,script)
AmmoValue.Name = “Ammo”
AmmoValue.Value = Module.LimitedAmmoEnabled and Module.Ammo or 0
local HeatValue = script:FindFirstChild(“Heat”) or Instance.new(“NumberValue”,script)
HeatValue.Name = “Heat”
HeatValue.Value = 0
if Module.IdleAnimationID ~= nil or Module.DualEnabled then
local IdleAnim = Instance.new(“Animation”,Tool)
IdleAnim.Name = “IdleAnim”
IdleAnim.AnimationId = “rbxassetid://”…(Module.DualEnabled and nil or Module.IdleAnimationID)
end
if Module.FireAnimationID ~= nil then
local FireAnim = Instance.new(“Animation”,Tool)
FireAnim.Name = “FireAnim”
FireAnim.AnimationId = “rbxassetid://”…Module.FireAnimationID
end
if Module.ReloadAnimationID ~= nil then
local ReloadAnim = Instance.new(“Animation”,Tool)
ReloadAnim.Name = “ReloadAnim”
ReloadAnim.AnimationId = “rbxassetid://”…Module.ReloadAnimationID
end
if Module.ShotgunClipinAnimationID ~= nil then
local ShotgunClipinAnim = Instance.new(“Animation”,Tool)
ShotgunClipinAnim.Name = “ShotgunClipinAnim”
ShotgunClipinAnim.AnimationId = “rbxassetid://”…Module.ShotgunClipinAnimationID
end
if Module.ShotgunPumpinAnimationID ~= nil then
local ShotgunPumpinAnim = Instance.new(“Animation”,Tool)
ShotgunPumpinAnim.Name = “ShotgunPumpinAnim”
ShotgunPumpinAnim.AnimationId = “rbxassetid://”…Module.ShotgunPumpinAnimationID
end
if Module.HoldDownAnimationID ~= nil then
local HoldDownAnim = Instance.new(“Animation”,Tool)
HoldDownAnim.Name = “HoldDownAnim”
HoldDownAnim.AnimationId = “rbxassetid://”…Module.HoldDownAnimationID
end
if Module.EquippedAnimationID ~= nil then
local EquippedAnim = Instance.new(“Animation”,Tool)
EquippedAnim.Name = “EquippedAnim”
EquippedAnim.AnimationId = “rbxassetid://”…Module.EquippedAnimationID
end
if Module.SecondaryFireAnimationEnabled and Module.SecondaryFireAnimationID ~= nil then
local SecondaryFireAnim = Instance.new(“Animation”,Tool)
SecondaryFireAnim.Name = “SecondaryFireAnim”
SecondaryFireAnim.AnimationId = “rbxassetid://”…Module.SecondaryFireAnimationID
end
if Module.SecondaryShotgunPump and Module.SecondaryShotgunPumpinAnimationID ~= nil then
local SecondaryShotgunPumpinAnim = Instance.new(“Animation”,Tool)
SecondaryShotgunPumpinAnim.Name = “SecondaryShotgunPumpinAnim”
SecondaryShotgunPumpinAnim.AnimationId = “rbxassetid://”…Module.SecondaryShotgunPumpinAnimationID
end
if Module.AimAnimationsEnabled and Module.AimIdleAnimationID ~= nil then
local AimIdleAnim = Instance.new(“Animation”,Tool)
AimIdleAnim.Name = “AimIdleAnim”
AimIdleAnim.AnimationId = “rbxassetid://”…Module.AimIdleAnimationID
end
if Module.AimAnimationsEnabled and Module.AimFireAnimationID ~= nil then
local AimFireAnim = Instance.new(“Animation”,Tool)
AimFireAnim.Name = “AimFireAnim”
AimFireAnim.AnimationId = “rbxassetid://”…Module.AimFireAnimationID
end
if Module.AimAnimationsEnabled and Module.AimSecondaryFireAnimationID ~= nil then
local AimSecondaryFireAnim = Instance.new(“Animation”,Tool)
AimSecondaryFireAnim.Name = “AimSecondaryFireAnim”
AimSecondaryFireAnim.AnimationId = “rbxassetid://”…Module.AimSecondaryFireAnimationID
end
if Module.AimAnimationsEnabled and Module.AimChargingAnimationID ~= nil then
local AimChargingAnim = Instance.new(“Animation”,Tool)
AimChargingAnim.Name = “AimChargingAnim”
AimChargingAnim.AnimationId = “rbxassetid://”…Module.AimChargingAnimationID
end
if Module.TacticalReloadAnimationEnabled and Module.TacticalReloadAnimationID ~= nil then
local TacticalReloadAnim = Instance.new(“Animation”,Tool)
TacticalReloadAnim.Name = “TacticalReloadAnim”
TacticalReloadAnim.AnimationId = “rbxassetid://”…Module.TacticalReloadAnimationID
end
if Module.InspectAnimationEnabled and Module.InspectAnimationID ~= nil then
local InspectAnim = Instance.new(“Animation”,Tool)
InspectAnim.Name = “InspectAnim”
InspectAnim.AnimationId = “rbxassetid://”…Module.InspectAnimationID
end
if Module.ShotgunReload and Module.PreShotgunReload and Module.PreShotgunReloadAnimationID ~= nil then
local PreShotgunReloadAnim = Instance.new(“Animation”,Tool)
PreShotgunReloadAnim.Name = “PreShotgunReloadAnim”
PreShotgunReloadAnim.AnimationId = “rbxassetid://”…Module.PreShotgunReloadAnimationID
end
if Module.MinigunRevUpAnimationID ~= nil then
local MinigunRevUpAnim = Instance.new(“Animation”,Tool)
MinigunRevUpAnim.Name = “MinigunRevUpAnim”
MinigunRevUpAnim.AnimationId = “rbxassetid://”…Module.MinigunRevUpAnimationID
end
if Module.MinigunRevDownAnimationID ~= nil then
local MinigunRevDownAnim = Instance.new(“Animation”,Tool)
MinigunRevDownAnim.Name = “MinigunRevDownAnim”
MinigunRevDownAnim.AnimationId = “rbxassetid://”…Module.MinigunRevDownAnimationID
end
if Module.ChargingAnimationEnabled and Module.ChargingAnimationID ~= nil then
local ChargingAnim = Instance.new(“Animation”,Tool)
ChargingAnim.Name = “ChargingAnim”
ChargingAnim.AnimationId = “rbxassetid://”…Module.ChargingAnimationID
end
if Module.SelectiveFireEnabled and Module.SwitchAnimationID ~= nil then
local SwitchAnim = Instance.new(“Animation”,Tool)
SwitchAnim.Name = “SwitchAnim”
SwitchAnim.AnimationId = “rbxassetid://”…Module.SwitchAnimationID
end
if Module.BatteryEnabled and Module.OverheatAnimationID ~= nil then
local OverheatAnim = Instance.new(“Animation”,Tool)
OverheatAnim.Name = “OverheatAnim”
OverheatAnim.AnimationId = “rbxassetid://”…Module.OverheatAnimationID
end
ChangeMagAndAmmo.OnServerEvent:connect(function(Player,Mag,Ammo,Heat)
MagValue.Value = Mag
AmmoValue.Value = Ammo
HeatValue.Value = Heat
end)
Tool.Equipped:connect(function()
–Player = game.Players:GetPlayerFromCharacter(Tool.Parent)
–Character = Tool.Parent
–Humanoid = Character:FindFirstChild(“Humanoid”)
if Module.DualEnabled and workspace.FilteringEnabled then
Handle2.CanCollide = false
local LeftArm = Tool.Parent:FindFirstChild(“Left Arm”) or Tool.Parent:FindFirstChild(“LeftHand”)
local RightArm = Tool.Parent:FindFirstChild(“Right Arm”) or Tool.Parent:FindFirstChild(“RightHand”)
if RightArm then
local Grip = RightArm:WaitForChild(“RightGrip”,0.01)
if Grip then
Grip2 = Grip:Clone()
Grip2.Name = “LeftGrip”
Grip2.Part0 = LeftArm
Grip2.Part1 = Handle2
–Grip2.C1 = Grip2.C1:inverse()
Grip2.Parent = LeftArm
end
end
end
end)
Tool.Unequipped:connect(function()
if Module.DualEnabled and workspace.FilteringEnabled then
Handle2.CanCollide = true
if Grip2 then Grip2:Destroy() end
end
end)
dont mind me just making it into a code cuz i cant understand
local Tool = script.Parent
local Handle = Tool:WaitForChild(“Handle”)
–local Player
–local Character
–local Humanoid
local Module = require(Tool:WaitForChild(“Setting”))
local ChangeMagAndAmmo = script:WaitForChild(“ChangeMagAndAmmo”)
local Grip2
local Handle2
if Module.DualEnabled then
Handle2 = Tool:WaitForChild(“Handle2”,1)
if Handle2 == nil and Module.DualEnabled then error("“Dual” setting is enabled but “Handle2” is missing!") end
end
local MagValue = script:FindFirstChild(“Mag”) or Instance.new(“NumberValue”,script)
MagValue.Name = “Mag”
MagValue.Value = Module.AmmoPerMag
local AmmoValue = script:FindFirstChild(“Ammo”) or Instance.new(“NumberValue”,script)
AmmoValue.Name = “Ammo”
AmmoValue.Value = Module.LimitedAmmoEnabled and Module.Ammo or 0
local HeatValue = script:FindFirstChild(“Heat”) or Instance.new(“NumberValue”,script)
HeatValue.Name = “Heat”
HeatValue.Value = 0
if Module.IdleAnimationID ~= nil or Module.DualEnabled then
local IdleAnim = Instance.new(“Animation”,Tool)
IdleAnim.Name = “IdleAnim”
IdleAnim.AnimationId = “rbxassetid://”…(Module.DualEnabled and nil or Module.IdleAnimationID)
end
if Module.FireAnimationID ~= nil then
local FireAnim = Instance.new(“Animation”,Tool)
FireAnim.Name = “FireAnim”
FireAnim.AnimationId = “rbxassetid://”…Module.FireAnimationID
end
if Module.ReloadAnimationID ~= nil then
local ReloadAnim = Instance.new(“Animation”,Tool)
ReloadAnim.Name = “ReloadAnim”
ReloadAnim.AnimationId = “rbxassetid://”…Module.ReloadAnimationID
end
if Module.ShotgunClipinAnimationID ~= nil then
local ShotgunClipinAnim = Instance.new(“Animation”,Tool)
ShotgunClipinAnim.Name = “ShotgunClipinAnim”
ShotgunClipinAnim.AnimationId = “rbxassetid://”…Module.ShotgunClipinAnimationID
end
if Module.ShotgunPumpinAnimationID ~= nil then
local ShotgunPumpinAnim = Instance.new(“Animation”,Tool)
ShotgunPumpinAnim.Name = “ShotgunPumpinAnim”
ShotgunPumpinAnim.AnimationId = “rbxassetid://”…Module.ShotgunPumpinAnimationID
end
if Module.HoldDownAnimationID ~= nil then
local HoldDownAnim = Instance.new(“Animation”,Tool)
HoldDownAnim.Name = “HoldDownAnim”
HoldDownAnim.AnimationId = “rbxassetid://”…Module.HoldDownAnimationID
end
if Module.EquippedAnimationID ~= nil then
local EquippedAnim = Instance.new(“Animation”,Tool)
EquippedAnim.Name = “EquippedAnim”
EquippedAnim.AnimationId = “rbxassetid://”…Module.EquippedAnimationID
end
if Module.SecondaryFireAnimationEnabled and Module.SecondaryFireAnimationID ~= nil then
local SecondaryFireAnim = Instance.new(“Animation”,Tool)
SecondaryFireAnim.Name = “SecondaryFireAnim”
SecondaryFireAnim.AnimationId = “rbxassetid://”…Module.SecondaryFireAnimationID
end
if Module.SecondaryShotgunPump and Module.SecondaryShotgunPumpinAnimationID ~= nil then
local SecondaryShotgunPumpinAnim = Instance.new(“Animation”,Tool)
SecondaryShotgunPumpinAnim.Name = “SecondaryShotgunPumpinAnim”
SecondaryShotgunPumpinAnim.AnimationId = “rbxassetid://”…Module.SecondaryShotgunPumpinAnimationID
end
if Module.AimAnimationsEnabled and Module.AimIdleAnimationID ~= nil then
local AimIdleAnim = Instance.new(“Animation”,Tool)
AimIdleAnim.Name = “AimIdleAnim”
AimIdleAnim.AnimationId = “rbxassetid://”…Module.AimIdleAnimationID
end
if Module.AimAnimationsEnabled and Module.AimFireAnimationID ~= nil then
local AimFireAnim = Instance.new(“Animation”,Tool)
AimFireAnim.Name = “AimFireAnim”
AimFireAnim.AnimationId = “rbxassetid://”…Module.AimFireAnimationID
end
if Module.AimAnimationsEnabled and Module.AimSecondaryFireAnimationID ~= nil then
local AimSecondaryFireAnim = Instance.new(“Animation”,Tool)
AimSecondaryFireAnim.Name = “AimSecondaryFireAnim”
AimSecondaryFireAnim.AnimationId = “rbxassetid://”…Module.AimSecondaryFireAnimationID
end
if Module.AimAnimationsEnabled and Module.AimChargingAnimationID ~= nil then
local AimChargingAnim = Instance.new(“Animation”,Tool)
AimChargingAnim.Name = “AimChargingAnim”
AimChargingAnim.AnimationId = “rbxassetid://”…Module.AimChargingAnimationID
end
if Module.TacticalReloadAnimationEnabled and Module.TacticalReloadAnimationID ~= nil then
local TacticalReloadAnim = Instance.new(“Animation”,Tool)
TacticalReloadAnim.Name = “TacticalReloadAnim”
TacticalReloadAnim.AnimationId = “rbxassetid://”…Module.TacticalReloadAnimationID
end
if Module.InspectAnimationEnabled and Module.InspectAnimationID ~= nil then
local InspectAnim = Instance.new(“Animation”,Tool)
InspectAnim.Name = “InspectAnim”
InspectAnim.AnimationId = “rbxassetid://”…Module.InspectAnimationID
end
if Module.ShotgunReload and Module.PreShotgunReload and Module.PreShotgunReloadAnimationID ~= nil then
local PreShotgunReloadAnim = Instance.new(“Animation”,Tool)
PreShotgunReloadAnim.Name = “PreShotgunReloadAnim”
PreShotgunReloadAnim.AnimationId = “rbxassetid://”…Module.PreShotgunReloadAnimationID
end
if Module.MinigunRevUpAnimationID ~= nil then
local MinigunRevUpAnim = Instance.new(“Animation”,Tool)
MinigunRevUpAnim.Name = “MinigunRevUpAnim”
MinigunRevUpAnim.AnimationId = “rbxassetid://”…Module.MinigunRevUpAnimationID
end
if Module.MinigunRevDownAnimationID ~= nil then
local MinigunRevDownAnim = Instance.new(“Animation”,Tool)
MinigunRevDownAnim.Name = “MinigunRevDownAnim”
MinigunRevDownAnim.AnimationId = “rbxassetid://”…Module.MinigunRevDownAnimationID
end
if Module.ChargingAnimationEnabled and Module.ChargingAnimationID ~= nil then
local ChargingAnim = Instance.new(“Animation”,Tool)
ChargingAnim.Name = “ChargingAnim”
ChargingAnim.AnimationId = “rbxassetid://”…Module.ChargingAnimationID
end
if Module.SelectiveFireEnabled and Module.SwitchAnimationID ~= nil then
local SwitchAnim = Instance.new(“Animation”,Tool)
SwitchAnim.Name = “SwitchAnim”
SwitchAnim.AnimationId = “rbxassetid://”…Module.SwitchAnimationID
end
if Module.BatteryEnabled and Module.OverheatAnimationID ~= nil then
local OverheatAnim = Instance.new(“Animation”,Tool)
OverheatAnim.Name = “OverheatAnim”
OverheatAnim.AnimationId = “rbxassetid://”…Module.OverheatAnimationID
end
ChangeMagAndAmmo.OnServerEvent:connect(function(Player,Mag,Ammo,Heat)
MagValue.Value = Mag
AmmoValue.Value = Ammo
HeatValue.Value = Heat
end)
Tool.Equipped:connect(function()
–Player = game.Players:GetPlayerFromCharacter(Tool.Parent)
–Character = Tool.Parent
–Humanoid = Character:FindFirstChild(“Humanoid”)
if Module.DualEnabled and workspace.FilteringEnabled then
Handle2.CanCollide = false
local LeftArm = Tool.Parent:FindFirstChild(“Left Arm”) or Tool.Parent:FindFirstChild(“LeftHand”)
local RightArm = Tool.Parent:FindFirstChild(“Right Arm”) or Tool.Parent:FindFirstChild(“RightHand”)
if RightArm then
local Grip = RightArm:WaitForChild(“RightGrip”,0.01)
if Grip then
Grip2 = Grip:Clone()
Grip2.Name = “LeftGrip”
Grip2.Part0 = LeftArm
Grip2.Part1 = Handle2
–Grip2.C1 = Grip2.C1:inverse()
Grip2.Parent = LeftArm
end
end
end
end)
Tool.Unequipped:connect(function()
if Module.DualEnabled and workspace.FilteringEnabled then
Handle2.CanCollide = true
if Grip2 then Grip2:Destroy() end
end
end)
Im using R6 but also using a startercharacter
Sorry, I misspoke, meant to say the script was for R15. What’s your starter character looking like?
Its a roblox character rig but I doubt the startercharacters the problem
I just searched for words “Activated”, “Mouse”, “Button” and found none, maybe there are no click detectors, or maybe those are in the modules already
If the tool works in StarterGear/StarterPack but not upon cloning, it’s likely that the tool is not parented to ServerStorage. I’m pretty sure any code would run if it were put in workspace, and this might be the issue. Some parts of the code may not work if it’s not immediately in the character when executed.
A simple solution would be to parent the tool to ServerStorage, then clone and immediately reparent the tool to the backpack whenever it’s needed.
Another cheap workaround would simply be adding this to the beginning of every server script within the tool:
local tool = script.Parent --this is likely already defined in the scripts, but if not then add it
tool.Equipped:Wait()
I hope this helps you out.
I have a working method to fix this issue.
First, create a platform in workspace (make sure it’s anchored), bring the tools into workspace and place them on the platform, then group the tools and the platform.
I used a local script but you can try using a server script.
game.Workspace.GearStorage.TransparencyTool:Clone().Parent = game.Players.LocalPlayer.Backpack
What roblox character rig is it? And could you send us a screenshot of what’s inside of it? It could have missing parts.
Heres the screenshot