Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Teleporting a player according to an object Value, not working?

Asked by 6 years ago
Edited by SerpentineKing 6 years ago

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:

01local Plot = game.Workspace.Plots:GetChildren()
02local player = game.Players.LocalPlayer
03local Location = game.Workspace.Plots:GetChildren()[script.Parent:WaitForChild("Plot.Value")]
04local Character = player.Character
05 
06script.Parent.MouseButton1Click:Connect(function()
07    for i,plt in pairs(workspace.Plots:GetChildren()) do
08        if plt then
09            if plt.Plot.Owner.Value == player then
10                wait(1)
11                Character:MoveTo(Location.Position)
12                game.Workspace.PlotBounds.Bound1.CanCollide = true
13                game.Workspace.PlotBounds.Bound2.CanCollide = true
14                game.Workspace.PlotBounds.Bound4.CanCollide = true
15                game.Workspace.PlotBounds.Bound5.CanCollide = true
View all 22 lines...
0
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. RubenKan 3615 — 6y

1 answer

Log in to vote
0
Answered by
starmaq 1290 Moderation Voter
6 years ago

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

1script.Parent:WaitForChild(Plot.Value)
Ad

Answer this question