Teleport Script Not Working

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Have the player be teleported on the Tycoon that the server has picked for them

  2. What is the issue? The player isnt being teleported

  3. What solutions have you tried so far? I’ve tried looking for people who had similar problems but It wasnt any help

function TycoonHandler.GiveTycoon(HumanoidRootPart)
	local Selected_Tycoon = OpenTycoons[math.random(1, #OpenTycoons)]
	for _, Physical_Tycoon in pairs(Tycoons) do
		if Selected_Tycoon == Physical_Tycoon.Name then
			repeat RunService.Heartbeat:Wait() until HumanoidRootPart
			HumanoidRootPart.CFrame = workspace.Part.CFrame
			TycoonInfos.TycoonInfos[Selected_Tycoon] = true
		end
	end
end

1 Like

How your getting the player character?

Can you post that function too?

1 Like
---//Services
local Players = game:GetService("Players")
local ServerScriptService = game:GetService("ServerScriptService")
local RunService = game:GetService("RunService")

---//Modules
local TycoonHandler = require(ServerScriptService:WaitForChild("TycoonHandler"))


local Tycoons = game.Workspace:WaitForChild("Tycoons"):GetChildren()


Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local HumanoidRootPart = character:WaitForChild("HumanoidRootPart")
		repeat RunService.Heartbeat:Wait() until HumanoidRootPart
		TycoonHandler.FindTycoon()
		TycoonHandler.GiveTycoon(HumanoidRootPart)
	end)
end)

I sonn realized my mistake I put an “:” instead of a “.”

1 Like
local HumanoidRootPart = character:WaitForChild("HumanoidRootPart")
repeat RunService.Heartbeat:Wait() until HumanoidRootPart

Second line here is unnecessary, first line yields the script’s execution until the character’s ‘HumanoidRootPart’ limb has replicated (loaded).

1 Like