Script says I still have tool in backpack even if I don't

So I’m making a shop GUI where if the player clicks buy it fires the remote event which checks if the player already owns the item then it would print already owns but if I delete the item then try to buy it still says already owns. This is my script:

-- WoodenBat
game.ReplicatedStorage.ShopEvents.WoodenBat.OnServerEvent:Connect(function(Player)
	local BatCheck = Player.Backpack:FindFirstChild("Bat") or Player.Character:FindFirstChild("Bat")
	if not BatCheck then
		Player.PlayerGui:FindFirstChild("ShopGui").MainFrame.WoodenBat.Error.Value = false
		Player.PlayerGui:FindFirstChild("ShopGui").MainFrame.WoodenBat.Purchased.Value = true
		game.ServerStorage.ShopItems.Bat:Clone().Parent = Player.Backpack
		print("ClonedTool")
	else if BatCheck then
		Player.PlayerGui:FindFirstChild("ShopGui").MainFrame.WoodenBat.Error.Value = true
			Player.PlayerGui:FindFirstChild("ShopGui").MainFrame.WoodenBat.Purchased.Value = false
			print("AlreadyOwns")
		end
	end		
end)

If you delete the tool from a local environment (whether that’s the Client view in test mode or a LocalScript), the deletion will not replicate to the server and it will still register the player as having the tool. You need to delete the tool from a server environment for this to work as intended.

2 Likes