What do you want to achieve?
I’d like the player, when teleported to face the same direction as the front of the part.
What is the issue?
I’m not really sure how I would do this. I’ve tried some solutions, more below.
What solutions have you tried so far?
I’ve looked through some other topics, but haven’t found anything relating to this (if you know of any a link to it would be great). I’ve already tried using CFrame, but this doesn’t work for whatever reason.
You may need to use RunService’s Heartbeat event, the CFrame will only change once from your script so you’ll need to put it through some loop to keep its consistent Orientation:
local RunService = game:GetService("RunService")
RunService.Heartbeat:Connect(function()
HRP.CFrame = workspace.Checkpoints[tostring(ServerData[Player].leaderstats.Level)].CFrame
end)
Utilice CFrame.lookAt () and Character:SetPrimaryPartCFrame():
local D = workspace.Checkpoints[tostring(ServerData[Player].leaderstats.Level)]
local Look = D.CFrame.LookVector * 2
Character:SetPrimaryPartCFrame(CFrame.lookAt(D.Position,Look))
--// Variables //--
local Checkpoints = game.Workspace:WaitForChild("Checkpoints")
--// Functions //--
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
if HumanoidRootPart then
if Checkpoints:FindFirstChild(tostring(ServerData[Player].leaderstats.Level.Value)) then
local Part = Checkpoints:WaitForChild(tostring(ServerData[Player].leaderstats.Level.Value))
HumanoidRootPart.CFrame = CFrame.new(Part.Position + Vector3.new(0, 3, 0))
end
end
end)
end)
I also tidied everything up into ModuleScripts, this doesn’t actually effect anything other than the code looking slightly better. DataModule:RequestData(Player, "Level") is the same as ServerData[Player].leaderstats.Level.