Why am I not teleporting?

but still my games in R6…

Also, is there any errors in output?

no theres no errors it just does every thing but does not tp

For now try

local plot = script.Parent.Parent.Plot
local owned = false

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
if owned == false then
owned = true
plot.Name = player.Name…“'sPlot”
character.Torso.CFrame = plot.Spawn.CFrame
end
end)
end)

Its basically the same just making it go directly to the spawn not 3 studs higher.

Nope still doesent teleport…

Interesting…I did some testing and it seems like there’s an issue where Roblox won’t teleport the player properly if it attempts to do so as soon as the character is added.

Here’s my testing code, feel free to modify it as you wish.

game:GetService("Players").PlayerAdded:Connect(function(player)
	print("Player joined the game!")
	player.CharacterAdded:Connect(function(char)
		print("Character added!")
			game:GetService("RunService").Heartbeat:Wait()
		char:SetPrimaryPartCFrame(workspace.Test.CFrame + Vector3.new(0,3,0))
	end)
end)

I would recommend you to put it in ServerScriptService instead of the workspace. You can also remote the print() functions as that’s just what I use for debugging.

The main thing that I added is game:GetService("RunService").Heartbeat:Wait(), which functionally is the same thing as wait() but has some benefits under the hood. That, for some reason, gives Roblox enough time to teleport the player.

I also changed the teleport to use char:SetPrimaryPartCFrame() instead of choosing a specific part. I believe both R6 and R15 have a HumanoidRootPart, so you don’t need to worry about that. Change the first part of the parameter (the workspace.Test.CFrame) to the CFrame of the plot.

Hope I helped! Feel free to ask any questions if you have any.

Resources:

but if I put it in server script service it wont work like I want it to. Im having it so you own your own plot when you join. If it were to be in server how would each player be at there own plot?

Instead of having an internal variable “owned”, you could have a boolValue instead. Or you could add a table inside the script that keeps track of each plot.

  • Put all the plots in a folder, call it whatever you want.
  • Inside each plot, have a boolValue of “Owned” (or you can skip this if you’re familiar with tables)
  • Inside the script, implement a loop that checks each plot of whether or not they’re owned.
  • If it’s not owned, teleport them to the plot and turn “Owned” to true.
1 Like

My game Timed obby is in r6 and i used this:

player.Character.HumanoidRootPart.Position = game.Workspace.Part -- change it to CFrame.

Thanks allot ill try it and let you know

Am I doing this right?

local plots = game.Workspace.Plots:GetChildren()

local openPlots = {}

function checkIfOwned()
for i = 1,#plots do
if plots[i].Owned == false then
table.insert(openPlots, plots[i])
end
end
end

At the start of the server, every plot should be unowned. So you can just do:

for _, item in ipairs(plots) do
    table.insert(openPlots, item)
end

Then when the player enters, you can do something like:

game:GetService("Players").PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
        game:GetService("RunService").Heartbeat:Wait()
        char:SetPrimaryPartCFrame(openPlots[1].CFrame + Vector3.new(0,3,0))
        table.remove(openPlots, 1)
    end)
end)

Let’s walk through this step by step.

  1. At the very beginning, we go through every plot inside the plot folder, and add it to our table.
  2. When the player joins (and their character loads), we give them the FIRST plot on our list.
  3. Then we remove the FIRST item from the table (because we just assigned it).

If you want to do some stuff with the plot (change the name to the player, etc.) you can do that before the table.remove().

Hope I helped!

1 Like