Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make an inventory and shop GUI like assassin?

Me and my friend are making a sword fighting game, and I'm trying to make a shop GUI and a inventory that saves. We have it so when you load into a map it gives you a class linked sword. I've looked at tutorials and the wiki and came up dry. I need to know how to make it so you can buy a knife like a dark walker for 5000 cash, then open your inventory equip it and it will load that and not the linked sword. I'm also not sure how to make the inventory save when you leave and rejoin.

Our give sword script:

local Sword = ServerStorage.Sword:Clone()
			Sword.Parent = player.Backpack
			
			local GameTag = Instance.new("BoolValue")
			GameTag.Name = "GameTag"
			GameTag.Parent = player.Character
			
		else
			
			if not player then
				table.remove(plrs,i)
			end
		end
	end
end

Lobby script:

while true do

Status.Value = "Waiting for 2 (or more) Players to Join!"

repeat wait(1) until game.Players.NumPlayers >= 2

Status.Value = "Intermission (15 seconds)"

wait(15)

local plrs = {}

for i, player in pairs (game.Players:GetPlayers())do
	if player then
		table.insert(plrs,player)
	end
end

wait(2)

local AvailableMaps = MapsFolder:GetChildren()

local ChosenMap = AvailableMaps[math.random(1,#AvailableMaps)]

Status.Value = ChosenMap.Name.." Chosen"

local ClonedMap = ChosenMap:Clone()
ClonedMap.Parent = workspace

Teleport to map script:

local AvailableMaps = MapsFolder:GetChildren()

local ChosenMap = AvailableMaps[math.random(1,#AvailableMaps)]

Status.Value = ChosenMap.Name.." Chosen"

local ClonedMap = ChosenMap:Clone()
ClonedMap.Parent = workspace


local SpawnPoints = ClonedMap:FindFirstChild("SpawnPoints")

if not SpawnPoints then
	print("SpawnPoints not found!")
end

local AvailableSpawnPoints = SpawnPoints:GetChildren()

for i, player in pairs(plrs) do
	if player then
		character = player.Character
		
		if character then
			
			
			character:FindFirstChild("HumanoidRootPart").CFrame = AvailableSpawnPoints[1].CFrame
			table.remove(AvailableSpawnPoints,1)

2 comments

2

This is AlvinBlox's script, go check out his part 5 on how to make sword fight game where he makes a Shop Gui!

0

We do not support third party code, system or free models https://youtu.be/1MappXJ51Oo?t=244

1 answer

This is a rather vague question, but I will give you some tips and resources to use to make this shop and inventory.

For some background, my initial inventory system was completely unplayable but I was proud that the items translated from server-side data to client-side GUI display.

My first recommendation is to start with the inventory rather than the shop. This will allow the shop to simply interact with your inventory script very easily. I would make the inventory a module script that contains all of the player's data getting saving and caching within that script if you don't want to do metatables. This can be seen in the code sample below:


local Inventory = {}
Inventory._inventories = {}
-- Sorry for all the underscores, I like using them quite a bit regardless of 'proper' notation

function Inventory._newInventory(player)
	if not Inventory._inventories[player] then
		Inventory._inventories[player] = {}
	end
end

function Inventory._addItem(player, itemName, amount)
	if not amount then
		amount = 1
	end

	if Inventory._inventores[player] then 
		if Inventory._inventories[player][itemName] then
			Inventory._inventories[player][itemName] = Inventory._inventories[player][itemName] + amount
		end
	end
end

return Inventory

This is a very simple inventory system, purely initializing the inventory and adding the capability to add items. If you understand the add function, a removal function shouldn't be very difficult. Adding the shop components onto this would be simple as well, because you would just have to manage player's money on the server and check if they have the required amount of money to buy an item when the item buy request comes through, if they do, then you give them the item, otherwise do nothing / send information back to the client to let them know that they need more money.

I hope this was helpful, upvote and solution me if so. Have a great day!

This discussion is preserved as it was. New answers, comments, and votes are closed.