Hey guys,
I'm making a homeowners tycoon. Basically, someone is supposed to join the server, pick a house, touch a mailbox, and own the home. Everything works fine, however, when someone already owns a home, they are able to buy another one. This could mean that someone is able to join the server and 'own' every home before anyone even gets to them. I'm not sure how to script this.
The script I'm using for the mailbox is this:
name = script.Parent
owner = name.Parent.OwnerName
while true do
if owner.Value ~= "" then
name.Name = "Homeowner : " .. owner.Value
else
name.Name = "Nobody Lives Here"
end
wait(2)
end
The script I'm using for the ownership is this:
local ting = 0 --debouncer
owner = script.Parent.Parent.Parent.OwnerName
function onTouched(hit)
if ting == 0 then --debounce check
ting = 1 --activate debounce
local check = hit.Parent:FindFirstChild("Humanoid")
if check ~= nil then --If a human is found, then
script.Parent.NewHouse:play()
wait(1)
script.Parent.NewHouse:remove()
local thisplr = game.Players:findFirstChild(hit.Parent.Name)
if (thisplr~=nil) then
local ownstyc = thisplr:findFirstChild("Tycoon")
if (ownstyc~=nil) then
if ownstyc.Value == 0 then
ownstyc.Value = 1
owner.Value = thisplr.Name
local message = Instance.new("Message")
message.Text = "You NOW own #1"
message.Parent = thisplr
wait(0.5)
message:remove()
script.Parent.Parent.Name = ""
script.Parent.CanCollide = false
elseif ownstyc.Value == 1 then
local message = Instance.new("Message")
message.Text = "You ALREADY own #2"
message.Parent = thisplr
wait(0.5)
message:remove()
end
end
end
end
ting = 0 --remove debounce
end
end
