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

Player not teleporting to a plot, how to fix?

Asked by 1 year ago
local AllPlots = workspace.Plots:GetChildren()
    for i, v in pairs(AllPlots) do
        if v[i].ClaimDoor.Rig.Rig.OwnerName.Value == "" then -- Plot is empty
            v[i].ClaimDoor.Rig.Rig.OwnerName.Value = Plr.Name
            workspace:WaitForChild(Plr.Name).PrimaryPart.CFrame = v[i].PrimaryPart.CFrame
            break
        end
    end

I was using this code from another answer, but it does not work.

0
how does this code not work? eg. are any errors showing that could explain why your code isn't functioning properly loowa_yawn 383 — 1y
0
yes bebokhouja2 38 — 1y
0
it says 1 is not a valid member bebokhouja2 38 — 1y

1 answer

Log in to vote
1
Answered by 1 year ago

You should provide more details, like: Does everything work except the teleport? When does this script fire? Does it loop until it has assigned any player that joins a plot or is it fired when something is activated?

It's hard to figure out the problem or write a script that you could adapt when we can't see the full script

Maybe this helps?

for i, v in pairs(game.Workspace.Plots:GetChildren()) do
    if v.ClaimDoor.Rig.Rig.OwnerName.Value == "" then -- Empty Plot
        v.ClaimDoor.Rig.Rig.OwnerName.Value = Plr.Name
        Plr.Character.HumanoidRootPart.CFrame = v.PrimaryPart.CFrame
    end
end
0
It says "attempt to index nil with HumanoidRootPart" bebokhouja2 38 — 1y
0
Then the problem is not the code you gave us, we will need more code to figure out the problem, for example we need to see the "Plr" variable being set SharkRayMaster 265 — 1y
0
its in a function put in the player added event bebokhouja2 38 — 1y
0
after some modification it worked thanks bebokhouja2 38 — 1y
Ad

Answer this question