Item not being found and cloned to backpack

I have made a buy script where you buy an item and it clones to your backpack from ServerStorage, but it does not work.

How the script is supposed to work is, that when the button is clicked, the currency is subtracted and the item is found in a folder in ServerStorage. Then, the item is cloned to the player’s backpack.

Everything in the script works until the part when the item has to be found.


	local plr = game.Players.LocalPlayer
	local Currency = plr.CurrencyFolder.Currency
	local ItemPrice = script.Parent.Parent.Price.Value
	local ItemName = script.Parent.Parent.ItemName.Value
	if Currency.Value >= ItemPrice then 
		Currency.Value = Currency.Value - ItemPrice
-- next 2 lines do not work
		local Item = game.ServerStorage:WaitForChild("StoredItems"):FindFirstChild(ItemName)
		Item:Clone().Parent = plr.Backpack

How do I fix this?

I’m assuming you’re using localscript. Localscript cannot access the ServerStorage, and you have to subtract your currency and clone the tool with ServerScript using RemoteEvent