Hey!
I’m trying to make my own admin commands, and I’m wondering if I could have assistance making a :to (player username) command that doesn’t teleport them to the exact position of the player, but teleports them just in front of them. Could I have some help with making a few lines of script that teleports you right in front of the player rather than in their exact position? A video is attached below with an example of this. NOTE: I don’t need the whole script with the command and that, I just need the few lines that will get the position of where the player needs to be teleported to based off of the other player’s position. Thanks!
2 Likes
Dynulax
(Dynulax)
August 4, 2021, 9:11am
#2
This?
PlayerHumanoid.RootPart.CFrame = TargetHumanoid.RootPart.CFrame + TargetHumanoid.RootPart.CFrame.LookVector * 5
3 Likes
Can I do this from a LocalScript or ServerScript?
Dynulax
(Dynulax)
August 4, 2021, 9:17am
#4
Both of them. wwwwwwwwwwwwwwwwwww
2 Likes
If I’ve made the name of a GUI I’m referencing using a remoteevent the players username that I have to teleport to and doing this won’t work:
game.ReplicatedStorage.LogAnsweredPTS.OnServerEvent:Connect(function(player, guiName)
local getplr = game.Players.guiName
How would I get the player?
Dynulax
(Dynulax)
August 4, 2021, 9:28am
#6
local getplr = game.Players[guiName]
1 Like
This works, thanks! But how would I make it so the player who teleported faces the other player? There’s no position property for it so… I’m confused
1 Like
Dynulax
(Dynulax)
August 4, 2021, 9:40am
#8
Here (You can also use CFrame.lookAt )
PlayerHumanoid.RootPart.CFrame = TargetHumanoid.RootPart.CFrame + TargetHumanoid.RootPart.CFrame.LookVector * 5
PlayerHumanoid.RootPart.CFrame = CFrame.new(PlayerHumanoid.RootPart.CFrame.Position, Vector3.new(TargetHumanoid.RootPart.CFrame.Position.X, PlayerHumanoid.RootPart.CFrame.Position.Y, TargetHumanoid.RootPart.CFrame.Position.Z)
1 Like
24Lego
(woo)
August 4, 2021, 9:44am
#9
player1.Character.HumanoidRootPart.CFrame = player2.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, -5)
Above solutions work too.
5 Likes
Dynulax:
PlayerHumanoid.RootPart.CFrame = TargetHumanoid.RootPart.CFrame + TargetHumanoid.RootPart.CFrame.LookVector * 5
PlayerHumanoid.RootPart.CFrame = CFrame.new(PlayerHumanoid.RootPart.CFrame.Position, Vector3.new(TargetHumanoid.RootPart.CFrame.Position.X, PlayerHumanoid.RootPart.CFrame.Position.Y, TargetHumanoid.RootPart.CFrame.Position.Z)
Do I need to add another ) at the end or will that ruin the whole script? It says I need to.
Dynulax
(Dynulax)
August 4, 2021, 9:48am
#11
Oh yea I forgot to put it, sorry. : )
1 Like
No worries! However this doesn’t work, it just teleports me to a random place off the map and kills me.
Hey! Thanks, this works, but this doesn’t make the player face the one it teleports to.
Bumping this post, still need help!
24Lego
(woo)
August 4, 2021, 10:09am
#16
local hrp1 -- assume it is defined
local hrp2 -- assume it is defined
hrp1.CFrame = hrp2.CFrame * CFrame.new(0, 0, -5)
hrp1.CFrame = CFrame.new(hrp1.Position, hrp2.Position)
1 Like
This doesn’t work, it teleports me to a random place still.
local hrp1 = player.Character:WaitForChild("HumanoidRootPart")
local hrp2 = getplr.Character:WaitForChild("HumanoidRootPart")
hrp1.CFrame = hrp2.CFrame * CFrame.new(0, 0, -5)
hrp1.CFrame = CFrame.new(hrp1.Position, hrp2.Position)
1 Like
Bumping this post again, could anyone provide some help?
I still don’t have a solution to this. If you see this and think you can help, it’d be appreciated!
1 Like
Dynulax
(Dynulax)
August 4, 2021, 11:28am
#20
Mine should be working but I don’t understand why it didn’t work for you. Try figure it out.