local tycoons = game.Workspace.Tycoons:GetChildren()
local Mod = require(game.ServerScriptService.TycoonModule)
local Players = game:GetService("Players")
function ClaimPlot(hit,v)
local player = Players:GetPlayerFromCharacter(hit.Parent)
if hit.Parent:FindFirstChild("Humanoid") then
if player:FindFirstChild("HasClaim").Value == false then
Mod.SetOwner(hit.Parent, v.Owner)
player:FindFirstChild("HasClaim").Value = true
v:WaitForChild("ClaimPart"):Destroy()
else
print("e")
end
end
end -- End of function (ClaimPlot)
function BuyObject(player,v)
print(player.Name)
end
for i,v in ipairs(tycoons) do
for i,s in ipairs(tycoons.Buttons) do --Here is the problem
s.Click.ClickDetector.MouseClick:Connect(function(player)
BuyObject(player,v)
end)
end
end
for i,v in ipairs(tycoons) do
v.ClaimPart.Touched:connect(function(hit)
ClaimPlot(hit,v)
end)
end
local function PlayerLeave(player)
for i,v in ipairs(game.Workspace.Tycoons:GetChildren()) do
if player.Name == v:WaitForChild("Owner").Value then
local Backup = game.ReplicatedStorage.BackupFolder.Tycoon
local TycoonCFrame = v.Base.CFrame
local NewTycoon = Backup:Clone()
v:Destroy()
NewTycoon.PrimaryPart = NewTycoon.Base
NewTycoon.Parent = game.Workspace.Tycoons
NewTycoon:SetPrimaryPartCFrame(TycoonCFrame)
NewTycoon.ClaimPart.Touched:connect(function(hit)
ClaimPlot(hit,NewTycoon)
end)
end
end
end
game.Players.PlayerRemoving:Connect(PlayerLeave)
It won't loop thru the Buttons inside the line where it should have like -- Heres the problem Line 31 Can anyone help?

3 comments
First of all, tycoons is an array, so tycoons.Buttons won't exist. Second, you can't loop through an object. You need to use :GetChildren() to retrieve an array you can loop through.
Why are you using ipairs? Pairs should be your option, you aren't dealing with a numeric dictionary
Thanks - Got a new bug aswell .-.