Hey there! I’m Nepzerox, and I’m trying to create an admin system with a ‘to’ command. While I’m able to teleport the player to the other play, I need the teleported player to face the player, which I don’t currently know how to do. I know it involves CFrame.angles(), however I’m not very good with CFrame and need help.
My code:
['Name'] = 'To',
['Alias'] = nil,
['Description'] = 'Teleports you to a player',
['Arguments'] = {'[player]'},
['PlayerRequired'] = true,
-- ignore above, its just a table w/ information about the command
['Script'] = function(args, players, config, mod)
for i, v in pairs(players) do
if v.Character and mod.Character then
local char = v.Character
mod.Character.HumanoidRootPart.CFrame = char.HumanoidRootPart.CFrame * CFrame.new(0, 0, -5)
end
end
end
}
mod.Character:SetPrimaryPartCFrame(CFrame.lookAt(char.HumanoidRootPart.Position,mod.Character.HumanoidRootPart)) -- 2nd argument is position to look at! (vector3)
The second argument of a CFrame can be its ‘lookAt’ position.
Also, I think it’s better to use mod.Character:SetPrimaryPartCFrame(). I’ve had really annoying problems with not using that in the past.
(I only just realised that someone replied, but I’ll add something anyway)