|
| 26 Jul 2016 10:19 PM |
I've tried making several versions of script to do this. I'm having a hard time finding out if there is a simpler way of doing this.
The idea is you equip this tool. When you click on the screen your character teleports to that location. If you click in the sky it does nothing.
Here's an example of what I've tried. If there's a simpler way please lead me in that direction. Thanks!
Teleport = script.Parent player = script.Parent.Parent.Parent playerMouse = game.Players.LocalPlayer:GetMouse()
Teleport.Equipped:connect(function(eventMouse) eventMouse.Button1Down:connect(function() print("X: "..playerMouse.X..", Y: "..playerMouse.Y) print(player) script.Parent.Parent.Torso.CFrame = CFrame.new(Vector3.new(playerMouse.X,playerMouse.Y,10)) end) end)
|
|
|
| Report Abuse |
|
|
peIicans
|
  |
| Joined: 02 Nov 2013 |
| Total Posts: 1148 |
|
|
| 26 Jul 2016 10:29 PM |
make sure it's localscript
Teleport = script.Parent player = game.Players.LocalPlayer playerMouse = player:GetMouse() char = player.CharactedAdded:wait()
Teleport.Equipped:connect(function(eventMouse) eventMouse.Button1Down:connect(function() char:MoveTo(playerMouse.Hit.p) end) end)
|
|
|
| Report Abuse |
|
|
|
| 26 Jul 2016 10:49 PM |
That's exactly what I needed. Only thing I had to change was
char = player.CharactedAdded:wait() should be char = player.CharacterAdded:wait()
Thank you so much. The next thing I need to work on is a limitation of how far you can click. Such as 100 studs. I'll work on it for a bit but if someone has a suggestion I'd appreciate it.
Thanks again pelicans! |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2016 02:50 PM |
So to resolve the distance issue I was thinking of doing something like this.
playerxyz = playerMouse.Hit.p
I want to get 3 variables out of playerMouse.Hit.p and save them into an x, y, z variable. Once I do that I can use them to find out if the place that you click is within 100 studs of the player. How do I save playerMouse.Hit.p into 3 different x y z variables? |
|
|
| Report Abuse |
|
|
| |
|