-
What do you want to achieve?
I am hoping to create an admin command, “;to”, that teleports you 5 studs in front of a player of your choice, and have you facing them (in front and face to face). The command would look like this: ";to (player-name).
-
What is the issue?
I am unsure how to find where 5 studs in front of the player is along with rotating them according to the orientation of the player. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve searched google and youtube of tutorials on a “;to” command, but none show how to properly position the player to my liking.
--My full script
--// Chat Commands\\--
local cmds = {
";kick",
";to",
";fly"
}
local admins = {
"BoredMxghty",
"TheIsolatedUser",
"B1u6r",
"Player1",
"Player2"
}
game.Players.PlayerAdded:Connect(function(player)
local character = player.Character or player.CharacterAdded:Wait()
player.Chatted:Connect(function(message)
for i, v in pairs(admins) do
if player.Name == v then
local loweredMsg = string.lower(message)
local sep = string.split(loweredMsg, " ")
if sep[1] == cmds[1] then
local name = sep[2]
for i, plr in ipairs(game.Players:GetDescendants()) do
local foundName = string.lower(plr.Name)
if foundName == name then
local kicked = plr
kicked:FindFirstChild("Kicks").Value += 1
kicked:Kick("You were kicked")
end
end
elseif sep[1] == cmds[2] then
local name = sep[2]
for i, plr in ipairs(game.Players:GetDescendants()) do
local foundName = string.lower(plr.Name)
if foundName == name then
local to = plr.Character
character.HumanoidRootPart.CFrame = CFrame.new(to.HumanoidRootPart.Position) * CFrame.new(5,0,0)
character.HumanoidRootPart.CFrame = character.HumanoidRootPart.CFrame * CFrame.Angles(0,math.rad(180),0)
end
end
elseif sep[1] == cmds[3] then
local flown = sep[3]
local character = player.Character or player.CharacterAdded:Wait()
--character.Humanoid.StateType = Enum.HumanoidStateType.Flying
--WIP
end
end
end
end)
end)
--The area to focus on
elseif sep[1] == cmds[2] then
local name = sep[2]
for i, plr in ipairs(game.Players:GetDescendants()) do
local foundName = string.lower(plr.Name)
if foundName == name then
local to = plr.Character
character.HumanoidRootPart.CFrame = CFrame.new(to.HumanoidRootPart.Position) * CFrame.new(5,0,0)
character.HumanoidRootPart.CFrame = character.HumanoidRootPart.CFrame * CFrame.Angles(0,math.rad(180),0)
end
end
(Please let me know if I should post this somewhere else or delete.)