Delete all tools in inventory Apon death problem [SP]

what about cloning the item 2 times?

	local item = game.ServerStorage[itemName]:Clone()
	item.Parent = player.Backpack
	
	local item1 = game.ServerStorage[itemName]:Clone()
	item1.Parent = player.StarterGear

Yes, the script to buy the item is a local one… It’s weird tho, I got the shop GUI off a tutorial a while back and forgot how it worked (Figures)

local selectedItem = script.Parent.Parent.Parent:WaitForChild("SelectedItem")

local redColor = Color3.fromRGB(255,26,26)
local greenColor = Color3.fromRGB(2,234,111)

local timeDelay = 2
local success

script.Parent.MouseButton1Click:Connect(function()
	
		-- Remote function request
		success = false
		if selectedItem.Value ~= nil then
			success = replicatedStorage.CheckSale:InvokeServer(selectedItem.Value)
		end
		
		if success then
			
			script.Parent.TextColor3 = greenColor
			script.Parent.Text = "Purchased!"
			wait(timeDelay)
			script.Parent.Text = "Buy"
			
		else
			
			script.Parent.TextColor3 = redColor
			script.Parent.Text = "Purchase Failed!"
			wait(timeDelay)
			script.Parent.TextColor3 = greenColor
			script.Parent.Text = "Buy"
			
			
		end
	
	
	
end)```

Now here is the thing, because your shop is local, the server doesnt know it was added, you can switch between what a client sees and what a server sees, if you do that, you will see that the items would not be added.

Wait i didnt meant the item i meant the one that gives you it

I just tried that and it didn’t let me buy anything at all

try using remote events

just for reference:

game.ReplicatedStorage:WaitForChild('buy').OnServerEvent:Connect(function(player, itemName)
	if player.leaderstats.money.Value >= 50 then
		player.leaderstats.money.Value = player.leaderstats.money.Value-50
		
		local item = game.ServerStorage[itemName]:Clone()
		item.Parent = player.Backpack
		
		local item1 = game.ServerStorage[itemName]:Clone()
		item1.Parent = player.StarterGear
	else
		return
	end
end)

Forget what i just say, keep the gui on local, is the one that gives the items on local or server?

Each item called to a remote event in ReplicatedStorage called Checksale

Each item script:

local selectedItem = script.Parent.Parent.Parent:WaitForChild("SelectedItem")
local selectedImage = script.Parent.Parent.Parent:WaitForChild("ItemDescription").SelectedImage
local selectedName = selectedImage.SelectedName

script.Parent.MouseButton1Click:Connect(function()
	-- Remotefunction request
	local price = replicatedStorage.GetInfo:InvokeServer(script.Parent.Name)
	
	if price ~= nil then
		selectedName.Text = price.." Cash"
		selectedImage.Image = script.Parent.Image
		selectedItem.Value = script.Parent.Name
	end
end)
1 Like

See thats the thing, I have no idea what script it even is… they’re all local and call to a remote event in ReplicatedStorage

Then thats your problem, the one that clones and gives it to the backpack must be server

The Shop:

Im not asking for the gui, im asking for the one that gives it…

you dont need to call a whole event to get a price just make a variable

local price = 50 --amount you want to put
--after that you can call an event
event:FireServer(itemName, price)

You kind of do for security reasons

There are Int values in each item folder.

Screenshot 2023-09-09 165724

oh wait your kinda right… this one is more secure i think
@minecraftwolf1978 you can put prices in a table instead

local prices = {
	['gun'] = 50;
	['sword'] = 75;
	['speedcoil'] = 100;
}

--too lazy to change button scripts so dont mind the price variable
game.ReplicatedStorage:WaitForChild('buy').OnServerEvent:Connect(function(player, itemName, price)
	if player.leaderstats.money.Value >= prices[itemName] then
		player.leaderstats.money.Value = player.leaderstats.money.Value-prices[itemName]
		
		local item = game.ServerStorage[itemName]:Clone()
		item.Parent = player.Backpack
		
		local item1 = game.ServerStorage[itemName]:Clone()
		item1.Parent = player.StarterGear
	else
		return
	end
end)

Yes this is more like it, however i may know the reason of this problem, its prob because the script that gives the weapon is local instead of server

@minecraftwolf1978 can you please show me where the script is that gives the item to the player?

I’m sorry I am being vague, and it might sound hard to believe, but I have no idea how it even gives you the item. All I have is screenshots and snip-bits of how it works…

Can you send the tutorial atleast