|
| 03 Oct 2016 08:12 PM |
I currently have a script that limits the player from teleporting over 200 studs. However if the player clicks on a tall structure near the base with teleport they teleport to the top. How can I keep them from teleporting to the top?
################################################################################################################################################################################################################################################## mz = playerMouse.Hit.p.z px = player.Character.Torso.CFrame.x py = player.Character.Torso.CFrame.y pz = player.Character.Torso.CFrame.z if mx - px >= 200 or mx - px <= -200 then -- Limits them to 200 studs in any direction return end if my - py >= 200 or my - py <= -200 then return end if mz - pz >= 200 or mz - pz <= -200 then return end if player.Character.Torso.Anchored then -- If they are anchored it wont let them Teleport return end player.Character:MoveTo(playerMouse.Hit.p) end) end)
Creator of Dragon Ball After Future - https://www.roblox.com/games/454775590/Dragon-Ball-After-Future |
|
|
| Report Abuse |
|
|
|
| 03 Oct 2016 08:14 PM |
--Teleport = script.Parent --player = game.Players.LocalPlayer --playerMouse = player:GetMouse() --Teleport.Equipped:connect(function(eventMouse) --eventMouse.Button1Down:connect(function() --mx = playerMouse.Hit.p.x --my = playerMouse.Hit.p.y
Hoping this shows the beginning part. |
|
|
| Report Abuse |
|
|
Smeers
|
  |
| Joined: 14 Feb 2013 |
| Total Posts: 797 |
|
|
| 03 Oct 2016 08:16 PM |
You should be detecting the magnitude in between the player and the teleport destination. It will return the distance in studs.
(player.Character.Torso.CFrame.p - mouse.Hit.p).magnitude --Returns distance in between two Vector3 values in studs
if not (player.Character.Torso.CFrame.p - mouse.Hit.p).magnitude > 200 then -- teleport here end
|
|
|
| Report Abuse |
|
|
|
| 03 Oct 2016 09:46 PM |
I rewrote my script to this but I still am able to click on a very tall structure and be teleported to the top of the structure. Any other suggestions?
Player = game.Players.LocalPlayer Mouse = Player:GetMouse() TeleportRange = 200 script.Parent.Equipped:connect(function(eventMouse) eventMouse.Button1Down:connect(function() local Distance = (Mouse.Hit.p - Player.Character.Torso.Position).Magnitude if Distance < TeleportRange then Player.Character:MoveTo(Mouse.Hit.p) end end) end) |
|
|
| Report Abuse |
|
|
OldGoldie
|
  |
| Joined: 17 Aug 2010 |
| Total Posts: 8210 |
|
|
| 03 Oct 2016 09:48 PM |
Player = game.Players.LocalPlayer Mouse = Player:GetMouse() TeleportRange = 200 script.Parent.Equipped:connect(function(eventMouse) eventMouse.Button1Down:connect(function() local Distance = (Mouse.Hit.p - Player.Character.Torso.Position).Magnitude if Distance < TeleportRange then Player.Character.Torso.CFrame = Mouse.Hit.p end end) end)
This?
|
|
|
| Report Abuse |
|
|
Azodon123
|
  |
| Joined: 05 Apr 2012 |
| Total Posts: 140 |
|
|
| 03 Oct 2016 09:55 PM |
| I can't create a thread, suggestions? |
|
|
| Report Abuse |
|
|