How to make the player not be able to buy the same object?

  1. I am trying to make it to where when a player buys the object with [“POINTS”], the player who bought the object should not be able to buy it again.

  2. The issue is that nothing happens when the player interacts. When I remove the part where it checks if the player is in the table, it works fine but the player can buy the object again.

  3. I have tried inserting the player into a table and check if they are in the table to not fire the client.

local function onInteracted()
	local Points = ThePlayer.Character:WaitForChild("POINTS")
	local AmmoCheck = ThePlayer.Character:WaitForChild("AmmoCheck")
	local ReserveCheck = ThePlayer.Character:WaitForChild("ReserveCheck")
	
	if Points.Value >= Price and PlayersBoughtThis[ThePlayer] == false then
		Points.Value -= Price
		game.ReplicatedStorage.Indigo.SpecialEvents.PurchaseTriggerFinger:FireClient(ThePlayer)
		table.insert(PlayersBoughtThis, ThePlayer, true)
		Root.Song:Play()
	end

	if Points.Value <= Price then
		print("not enough")
	end
	
end

table.insert only inserts values with numbers as the key, so table.insert(PlayersBoughtThis, ThePlayer, true) would give an error.
you should use this:
PlayersBoughtThis[ThePlayer] = true

1 Like

Thank you so much, I have had a headache for too long