Delete all tools in inventory Apon death problem [SP]

Okay, I have to find it somewhere on YT. I think I just searched “How to make a GUI shop”

1 Like

can you send the code and the script locations

btw, i think your best option is to change your whole buying part of the system. BUT you can keep the parts where it shows the info etc

OH I HAVE THE SAME PROBLEM AS YOU HOLD UP

Okay, I finally found it:

Roblox Shop GUI Tutorial - Buy Items with Currency - YouTube

make a normal script. not a localscript
@minecraftwolf1978

game.Players.PlayerAdded:Connect(function(player)
	local character = player.CharacterAdded:Wait()
	local hum = character:WaitForChild('Humanoid')
	
	player.CharacterRemoving:Connect(function()
		for i, v in pairs(player.StarterGear:GetChildren()) do
			if v:IsA('Tool') then
				v:Destroy()
			end
			
			for i, v in pairs(player.Backpack:GetChildren()) do
				if v:IsA('Tool') then
					v:Destroy()
				end
			end
		end
	end)
end)

The tutorial I used:

Roblox Shop GUI Tutorial - Buy Items with Currency - YouTube

It didn’t work…

(Character limit)

is there a boughtTools folder??

It didn’t have that in the video, I don’t think. I was just following that a while ago to make it.

right… lemme follow this tutorial real quick ;-;

1 Like

Sorry man…

(Character limit, again)

no worries he linked the uncopylocked game so i just need to tweak ehheheeh

btw i found nothing wrong with the shop scripts when i die it still works

So it must be the local script in StarterPlayer

yeah i guess so :] you can replace it with a server script tho

(the code i posted before)

game.Players.PlayerAdded:Connect(function(player)--self explanitory, checks when player is added
	local character = player.CharacterAdded:Wait()
	local hum = character:WaitForChild('Humanoid')
	
	player.CharacterRemoving:Connect(function()
		for i, v in pairs(player.StarterGear:GetChildren()) do --loops through and destroys all tools
			if v:IsA('Tool') then
				v:Destroy()
			end
			
			for i, v in pairs(player.Backpack:GetChildren()) do --same with the other loop
				if v:IsA('Tool') then
					v:Destroy()
				end
			end
		end
	end)
end)

its almost 5 am… goodnight(morning) guys!

To clarify, you want players to be able to buy tools from the shop without being able to spawn with them.

Currently you have the server put tools into your player’s StarterGear, but the thing with StarterGear is that it doesn’t work as a ‘BackPack’ but more of a load out.

Can you confirm there is nothing in the StarterGear or StarterPack at the server side?

If all the server does is put tools into your backpack, then naturally, the player will respawn with nothing; you do not need a script to remove tools from your backpack.

Still didn’t work… If you’re leaving its fine, though

Two things about that.

One: The items go back into your inventory when you respawn (Without loop)
Two: On the Client side, you still have items in starterGear and Backpack (With loop)

And there is no script adding items to your Backpack when you respawn?
As I’ve said before, script to remove tools from your inventory is unnecessary, so the problem shouldn’t be the script. Just make sure there is nothing in StarterGear or StarterPack.

I followed a tutorial to make the shop GUI. I don’t know how it works, although there is a uncopylocked game to it…

Tutorial:
Roblox Shop GUI Tutorial - Buy Items with Currency - YouTube