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 5 years ago
Edited by SerpentineKing 5 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:

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)
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 — 5y

1 answer

Log in to vote
0
Answered by
starmaq 1290 Moderation Voter
5 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

script.Parent:WaitForChild(Plot.Value)
Ad

Answer this question