Guns not in the invetory after the player dies

alright so im working on an fps game. but the game has a problem i just noticed where, when the player dies the guns or just tools he had just arent there anymore. How do i fix this???

any help would be appreciated! :grinning:

1 Like

parent the tools to player.StarterPack, and not Player.Backpack.
also, wrong category.

1 Like

ay i aint tryna be annoying or sum. but how do i parent it to player.Starterpack?? im a bad dev and i dont understand most of the stuff. So again, sorry if im being annoying

1 Like

change the category to scripting-help.
are your tools given to the player by a script?

1 Like

No… theyre actually in starterpack

1 Like

is that bad that they aren’t given to the player by a script?

1 Like

weird, is there a script that clears the tools when the player dies?
if tools are in starterpack, they should automatically be parented to backpack once the player respawns.

in your case, i assume another script is interfering with the tools.

1 Like

No there are no scripts that clear the tool. there are only scripts in serverscriptservice that are used for bullets, chat tag, leaderstats, team handler. and thats all. the rest is just a fog in workspace and local scripts in the guns… if the tools are in starterpack and they should be given to the player by a script. could you somehow help me just make the script or where to place it? (god damn this is a long edit)

1 Like

i found the problem. i had a script that disables the invetory and enables it when a team is choosen. well i got my answer but i actually need that script so i dont have just the tools showing in the main menu.

2 Likes

if you want the tools to be given to the player by a script,
you can create a Folder, inside which all the tools are stored.

Next, create a Script in ServerScriptService.
This code is an example on how you would approach your goal.

local function GiveTool(Player,ToolName)
    local FolderWithTools = -- Location of the Folder
    FolderWithTools[ToolName]:Clone().Parent=Player:WaitForChild("Backpack")
end

local Player = -- Define the Player
local ToolName = "Your Tool Name"

GiveTool(Player,ToolName) -- Run the Function
2 Likes

with the folderWithTools can i just like copy it as many times as i want and then in [ToolName] exactly type the name of every tool?

1 Like

do you want to give every single tool in the Folder to the Player?

1 Like

yeah yeah yeah yeah yeah (also im saying yeah few times because of course the text needs to be X characters long)

1 Like

If you want to give all the tools to the player,
you can loop through the Folder, and run the function for each tool.

Example,

local FolderWithTools = -- Location of the Folder
local function GiveTool(Player,ToolName)
    FolderWithTools[ToolName]:Clone().Parent=Player:WaitForChild("Backpack")
end

local Player = -- Define the Player

for i, v in pairs(FolderWithTools:GetChildren()) -- Looping through the Folder

   -- v is the individual tool inside the Folder
   GiveTool(Player,v.Name)
end
1 Like

the word “GiveTool” at the end is giving me a red thingy (yk when something is wrong) is that bad? or is it suppost to be like that?

1 Like

can you send a screenshot of the script?

1 Like

1 Like

you cannot get the Player by game.Players.LocalPlayer
in a Script. You can only do that in LocalScripts.

if you want the Player to Spawn with tools and also respawn with tools, you can try

local FolderWithTools = -- Define Folder With Tools
local function GiveTool(Player,ToolName)
	FolderWithTools[ToolName]:Clone().Parent=Player:WaitForChild("Backpack")
end

local PlayersService=game:GetService("Players") 

PlayersService.PlayerAdded:Connect(function(Player) -- You get the Player
	-- This code runs every time a new player joins the game
	local function GiveAllTools()
		for i, v in pairs(FolderWithTools:GetChildren()) do -- Looping through the Folder
			-- v is the individual tool inside the Folder
			GiveTool(Player,v.Name)
		end
	end
	if Player.Character then
		GiveAllTools()
	end
	Player.CharacterAdded:Connect(function(Character)
		GiveAllTools()
	end) 
end)
1 Like

so i just put this into that script u told me to put in ServerScriptService?

1 Like

Put the tool in ReplicatedStorage, detect whenever the player spawns in or whenever you want them to get the gun back. Then in a script(probably in serverscriptstorage/starter(pack/gui)), clone the tool and put that clone into the players playerpack.

1 Like