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)