Tools not working after using shop script

I wanted to make a shop where players get an item and the money gets removed from leaderstats.
The items are located on replicated storage, after i buy i receive the ittem but it doesnt work. I already tried with multiple items and all have the same issue. When I put them on startwerplayer they work but they dont on replicated storage.

How do I fix this?
Script:

-- Function to handle the purchase button click
local function PeriastronClicked()
	local player = game.Players.LocalPlayer

	-- Get the player's leaderstats
	local leaderstats = player:WaitForChild("leaderstats")

	-- Get the player's money value
	local moneyValue = leaderstats:WaitForChild("Money")

	-- Check if the player has enough money to make the purchase
	if moneyValue.Value >= 5000 then -- Adjust the price of the item here
		-- Subtract the item price from the player's money
		moneyValue.Value = moneyValue.Value - 10 -- Adjust the price of the item here

		-- Give the item to the player
		local item = game.ReplicatedStorage.Items.PoseidonsQuakeTrident:Clone()-- item
		item.Parent = player.Backpack
	else
		-- Player doesn't have enough money, display an error message or take appropriate action
		print("Not enough money to purchase the item!")
	end
end

-- button name
local Periastron = script.Parent -- Reference to the button itself

-- Connect the button click event to the purchaseButtonClicked function
Periastron.Activated:Connect(PeriastronClicked)

That’s a local script, it’s only gonna be working on the client, on the individual player’s device, the money value won’t be actually modified and the item isn’t gonna be “real”, that should be handled on the server.

When the button is pressed, you should fire a RemoteEvent which should be connected to that function (on a serverside script), the money will be removed and the item will actually work.

2 Likes

Maybe The tool Has RequiredHandle On. Turn That off And Maybe Then It will work? If It Has A Handle Inside Of The Tool Then No.