Why is CFrame not working in this situation?

Hello everyone! I have been making a bus stop for my game using and for some reason CFrame will not work.

I get the following error:
ServerScriptService.Teleport:5: attempt to index nil with ‘CFrame’ - Server - Teleport:5

Here is the script:
local TeleportEvent = game.ReplicatedStorage.TeleportEvent

TeleportEvent.OnServerEvent:Connect(function(Player, Position)

local TeleportPoint = game.Workspace.TeleportPoints:FindFirstChild(Position)

Player.Character.HumanoidRootPart.CFrame = TeleportPoint.CFrame

end)

I am a little confused. When using :FindFirstChild you mention Position. What is Position defined it?

Position is classified in the function.
It is also looking at the players position.

TeleportPoint is nil, and since you never check if it is nil, it will error.

Exactly what I was going to say. haha

I checked if it is nil and it worked. It took away the error but now the teleport doesn’t work.

That means the position you are teleporting to is invalid/doesn’t exist. I don’t know what’s firing this event, so I can’t really help you.

TeleportPoint

may have a position, but it doesn’t have a
.CFrame

or it is nil

local TeleportPoint = game.Workspace.TeleportPoints:FindFirstChild(Position)

This isn’t fetching a valid instance (as the error indicates), “TeleportPoint” is still a reference to nil after this assignment so when you attempt to index its “CFrame” property an error is thrown/raised as the script thinks you’re attempting to index the “CFrame” property of a nil value (which of course doesn’t exist).