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)
Sooo what's wrong here, :FindFirstChild(this is a paramater)
takes a string value (a string value is any chracter "inside this") as a paramater, and that value is the Name of the object that you're looking for. Putting "Plot.Value" as a value will make your script look for a part that's named Plot.Value its not taking the code inside the " " cuz anything that's inside those will not excute as a code, for a example if we do "print(game.Workspace)"
this will act up as a string value and the code will just read it as one. Get it? I hope you did.
This is waht you gotta do
script.Parent:WaitForChild(Plot.Value)