Hello, I wanted to make an owner plot like those classic tycoons but with clickdetectors. I’ve tried using that but it only half-worked. Heres the code:
local vac = script.Parent.Vacant
local occu = script.Parent.Occupied
vac.ClickDetector.MouseClick:Connect(function(plr)
local hrp = plr.Character.HumanoidRootPart
for i,v in pairs(hrp:GetChildren()) do
if v.Name:lower():find('pet') then
v.Anchored = true
v.Position = occu.Position + Vector3.new(0, 3, 0)
v.Parent = occu
occu.Position = occu.Position + Vector3.new(0, 2, 0)
occu.Transparency = 0
vac.Position = vac.Position - Vector3.new(0, 2, 0)
vac.Transparency = 1
script.Parent.PlotGui.PlotUser.Text = plr.Name.."'s pet plot"
script.Parent.PlayerID.Value = plr.UserId
end
end
end)
occu.ClickDetector.MouseClick:Connect(function(plr)
local hrp = plr.Character.HumanoidRootPart
for i,v in pairs(hrp:GetChildren()) do
if v.Name:lower():find('pet') then
if plr.UserId == script.Parent.PlayerID.Value then
v.Anchored = false
v.Parent = hrp
occu.Position = occu.Position - Vector3.new(0, 2, 0)
occu.Transparency = 1
vac.Position = vac.Position + Vector3.new(0, 2, 0)
vac.Transparency = 0
script.Parent.PlotGui.PlotUser.Text = "Nobody's pet plot"
else
occu.BrickColor = BrickColor.new("Really red")
wait(2)
occu.BrickColor = BrickColor.new("Persimmon")
end
end
end
end)