generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Limited Teleport

Previous Thread :: Next Thread 
DaveHereYouTube is not online. DaveHereYouTube
Joined: 13 May 2016
Total Posts: 213
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
DaveHereYouTube is not online. DaveHereYouTube
Joined: 13 May 2016
Total Posts: 213
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 is online. 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
DaveHereYouTube is not online. DaveHereYouTube
Joined: 13 May 2016
Total Posts: 213
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 is not online. 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 is not online. Azodon123
Joined: 05 Apr 2012
Total Posts: 140
03 Oct 2016 09:55 PM
I can't create a thread, suggestions?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image