Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Player not teleporting to a plot, how to fix?

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.

3 comments

0

how does this code not work? eg. are any errors showing that could explain why your code isn't functioning properly

0

yes

0

it says 1 is not a valid member

1 answer

✓ Accepted answer

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

4 comments

0

It says "attempt to index nil with HumanoidRootPart"

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

0

its in a function put in the player added event

0

after some modification it worked thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.