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

My TeleportToLevel Event does not work?

I made an event that would Teleport a Player to Any level he wants

Heres the code

TeleportToLevel.OnServerEvent:Connect(function(Player, Level)
	local Lvl = Player.leaderstats.Level
	local Spawn = workspace:WaitForChild(tostring(Level))
	
	Player.Character.HumanoidRootPart.CFrame = CFrame.new(Spawn.Position + Vector3.new(0,2,0))
	
	Lvl.Value = Level
end)

For some reason I get this error saying

08:51:58.985 - Position is not a valid member of Model

and its for this line:

Player.Character.HumanoidRootPart.CFrame = CFrame.new(Spawn.Position + Vector3.new(0,2,0))

3 comments

1

maybe try doing Player.Character.HumanoidRootPart.Cframe = Spawn.CFrame? The error has something to do with the spawn though, I think.

0

Ok let me see

0

It does not work!

1 answer

Is the object "Spawn" a model, if so, change line 5 to





Player.Character.HumanoidRootPart.CFrame = (Spawn:GetPrimaryPartCFrame() or Spawn:FindFirstChildOfClass("BasePart").CFrame) + Vector3.new(0, 5, 0)

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