How to prevent someone from becoming the owner of another booth when they become the owner of a booth

Since I live abroad, I use a translator. If the translation is weird, please let me know!

I created a script that allows you to become the owner of a booth through proxyprompt.

ProximityPrompt.Triggered:Connect(function(player)
	if Values.Owner.Value == nil then
		Values.Owner.Value = player
		ProximityPrompt.Enabled = false
	end
end)

(“Values” ​​is the path to the folder where the player’s values ​​will be saved)

When a player becomes the owner of a booth, the player’s value is stored in the booth and proxyprompt is disabled.

However, since only the proxyprompt for one’s own booth is disabled, the player can also become the owner of another booth. Can you tell me how to prevent a player from accessing proxypromts from other booths when he becomes the owner of one booth?

Please let me know… :cry:

You can create a for loop going trough all booths like

local hasbooth = false
for _, booth in pairs(workspace.Booths:GetChildren()) do
   if booth.Values.Owner.Value == player then
      hasbooth = true
      break
   end
end

if not hasbooth then
  -- code
end
3 Likes

Alternatively, you can create an ObjectValue inside of the player and change its value to the booth. Then do

if not player.Booth.Value then
     -- code
end
1 Like

Thank you very much!! Should I write the corresponding code in ServerScriptService?

I think that you should write it inside of the script that lets you become an owner of the booth.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.