I need help with this:
I want it so in my game, you can claim a property with a Proximity prompt…
If you claim the property, I want the player that claimed it, AKA the owner to be the only one allowed in…
What I have got below, does work.
local ProximityPrompt = script.Parent
ProximityPrompt.ActionText = "Claim here"
ProximityPrompt.Triggered:Connect(function(plr)
ProximityPrompt.ActionText = "Claimed by ".. plr.Name
end)
then after that, I would like it to verify the player that triggered the Proximity prompt, and then make that player the only one allowed in, or the only one who is allowed to lock, unlock and open the door. (The door can be opened by anyone if it is unlocked).
Help please!
Thanks 


local ProximityPrompt = script.Parent
ProximityPrompt.ActionText = "Claim here"
ProximityPrompt.Triggered:Connect(function(plr)
if not ProximityPrompt.ActionText:sub(1,7) == "Claimed" then
ProximityPrompt.ActionText = "Claimed by ".. plr.Name
else
print("This door was already claimed!")
end
end)
From here, you can create a separate script or a new code block for the locking mechanics.
Thank you, but when I am given code, I like to understand it. Can you explain the
ProximityPrompt.Triggered:Connect(function(plr)
if not ProximityPrompt.ActionText:sub(1,7) == "Claimed" then
ProximityPrompt.ActionText = "Claimed by ".. plr.Name
That is the only bit I don’t understand
That is how I learn to get better 
Understandable.
The :sub(i,j)
method, or the string.sub(str,i,j)
function is returns the substring of s (string) that starts at i and ends at j. In more simpler words:
ProximityPrompt.ActionText:sub(1,7)
would get
"Claimed"
because those are the first 7 characters of the string. (characters 1 through 7)
Another example would be:
ProximityPrompt.ActionText:sub(1,4)
-- This would return "Clai" since those are the first four characters
Final example:
ProximityPrompt.ActionText:sub(2,5)
-- This would return "laim" since it got the characters after 2, until 5.
Note that in the way I used this function, we checked to make sure the beginning text was NOT “Claimed”. Which leaves us with:
if not ProximityPrompt.ActionText:sub(1,7) == "Claimed" then
Since ‘Claimed’ is the first 7 gathered characters, we’re checking if the substring of ActionText (1,7) is NOT “Claimed”, meaning it has not been claimed yet.
Thanks! I will test if it works now! 
Just another example to make it a bit more simpler.
local myString = "Hello world! My name is programher"
print(myString:sub(1,12))
--> "Hello world!" (first 12 characters)
I get this now! I am just testing if it will work!
Edit: for some reason I can’t test because it keeps kicking me off studio… 
1 Like
Sorry to disturb you… It doesn’t work. Sorry 
1 Like
You can disconnect the event, for the door’s you can use a number with the player’s userid.
local ProximityPrompt = script.Parent
ProximityPrompt.ActionText = "Claim here"
local Door = -- path to the door
local Connection
local OwnerId = 1
local Locked = false
local ClickDetector = Instance.new("ClickDetector")
ClickDetector.Parent = Door
Connection = ProximityPrompt.Triggered:Connect(function(plr)
ProximityPrompt.ActionText = "Claimed by ".. plr.Name
OwnerId = plr.UserId
Connection:Disconnect()
end)
ClickDetector.MouseClick:Connect(function(plr)
if Locked and OwnerId ~= plr.UserId then
return
end
-- door stuff here
end)