I am trying to make this script give a player a plot for them to build on, but it won’t set the owners value. I have been looking through this code for 10 minutes, and I can’t see the problem.
local plots = script.Parent.Plot
local plot
local function giveplot(plr)
print("PlotGiver fired!")
for i, plot in pairs(plots:GetChildren()) do
print("Looping...")
if plot:WaitForChild("Owner").Value ~= nil then
print("Owner!")
print(players:FindFirstChild(tostring(plot.Owner.Value)))
else
print("No owner!")
plot:WaitForChild("Owner").Value = plr
plot = plot
game.ReplicatedStorage.GivenPlot:FireClient(plr, plot)
break
end
end
end
players.PlayerAdded:Connect(giveplot)
That looks like mine, it definitely should be printing Looping. Is there anything that could be destroying the Grids? Any other scripts that access them?
If there’s no errors, I don’t know why your script doesn’t work. I can run your script and have it work fine, so it’s probably the issue of another script in your game.
I believe the problem here is your checking all the descendants of the plot folder, including those scripts. Since the scripts don’t have an Owner value, it’s infinitely waiting. Try adding: if plot:IsA(“Part”) then, right after your loop starts. Don’t forget to add in another end as well.