Hello! So I’ve scripted my own admin commands but there is one problem. The To-Command is working wrong. It’s not teleporting the player infront of the other player, more like next to him.
Script:
if splits[1]:lower() == MrCommands["To-Command"] and plr.leaderstats.Rank.Value >= 5 then
--Find the player
for i,v in pairs(game.Players:GetChildren()) do
if v.Name:sub(1, name:len()):lower() == name:lower() then
--v is the correct player
local vHumRootPart = v.Character:FindFirstChild("HumanoidRootPart")
local myHumRootPart = plr.Character:FindFirstChild("HumanoidRootPart")
myHumRootPart.CFrame = vHumRootPart.CFrame * CFrame.new(10, 0, 0)
end
end
end
You should only use the LookVector variable for directional/rotational purposes, not for positional purposes. You should use a position reference (and YES, i know that you not are using the LookVector Vector as position reference, only to avoid that people… You know):
This was my whole line of code your forgot to offset it by the HumRootPartCFrame.
And the lookVector returns a Unit Vector in the direction the player is looking at in this case
Sets your cframe to the same as your target but 10 studs in front relative to their cframe.
You can also multiply it by CFrame.Angles(0, math.pi, 0) so that you are facing your target when you teleport.