Hello!
I utilized a tycoon door script to allow a local player to pick a particular home in a game:
--//Variables local owner = script.Parent.OwnerName local isOpen = false local waitTime = 2 local door = script.Parent --//Ensures that the door is closed door.CanCollide = true door.Transparency = 0 door.Anchored = true script.Parent.Touched:connect(function(hit) local humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid then local plr = game.Players:GetPlayerFromCharacter(hit.Parent) if plr then --//A player if owner.Value == "" then --//No Current Owner, set player as new owner owner.Value = plr.Name elseif plr.Name == owner.Value then --//The owner if isOpen == false then isOpen = true door.CanCollide = false door.Transparency = 0.8 wait(waitTime) door.CanCollide = true door.Transparency = 0 isOpen = false end else --//Not the owner humanoid.Health = 0 end end end end)
This script works great but it allows the same player to take over as many properties as they want. Is there something I can add that will only allow them to get one house & prevent multiple ownerships?
I am trying to make sure they do not come in game and take multiple properties.
Thanks!
To solve this problem, I would advise these things:
Before starting,
Place a BoolValue
in the each house/property. Name: IsClaimed
Place another BoolValue
, but this time in the player. Name: OwnsAHouse
When claiming a new property,
If the property is already claimed, (by telling if "IsClaimed" is true)
If the property is not claimed, (by telling if "IsClaimed" is false)
Make "IsClaimed" to true
Get the player,