I want to be able that, when a player clicks on a GUI (Build), they teleport to a part that has an ObjectValue, in this case their username
Though, I always get the error: "attempt to index up Value 'Plot'" or "Infinite yield possible on WaitForChild["Plot.Value"]"
I am a beginner btw, here is my script:
local Plot = game.Workspace.Plots:GetChildren()
local player = game.Players.LocalPlayer
local Location = game.Workspace.Plots:GetChildren()[script.Parent:WaitForChild("Plot.Value")]
local Character = player.Character
script.Parent.MouseButton1Click:Connect(function()
for i,plt in pairs(workspace.Plots:GetChildren()) do
if plt then
if plt.Plot.Owner.Value == player then
wait(1)
Character:MoveTo(Location.Position)
game.Workspace.PlotBounds.Bound1.CanCollide = true
game.Workspace.PlotBounds.Bound2.CanCollide = true
game.Workspace.PlotBounds.Bound4.CanCollide = true
game.Workspace.PlotBounds.Bound5.CanCollide = true
script.Parent.Parent.Visible = false
script.Parent.Parent.Parent.ExitBuildMode.Visible = true
script.Parent.Parent.Parent.ExitBuildMode.TextLabel.Visible = true
end
end
end
end)

1 comment
In your WaitForChild("Plot.Value"), you gotta remove the "", else it's actually going to search for something named "Plot.Value" instead of using the value property of Plot.