Advertisement
lucky4291

Distance to Part GUI

Jul 24th, 2018
1,796
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.69 KB | None | 0 0
  1. --Script made by lucky4291. Tutorial found here:
  2. --https://www.youtube.com/watch?v=YX802PLAWmE
  3.  
  4. --Client Script
  5. local player = game.Players.LocalPlayer
  6. local gui = player:WaitForChild("PlayerGui")
  7. local ui = gui:WaitForChild("DistanceGui")
  8.  
  9. game.Workspace.Distance.Changed:Connect(function(value)
  10.     ui.txtDistance.Text = value
  11. end)
  12.  
  13. --DistanceScript Script
  14. local distance = game.Workspace.Distance
  15.  
  16. local player = game.Players.LocalPlayer
  17. local part1 = player.Character.HumanoidRootPart
  18.  
  19. local part2 = game.Workspace.Part
  20.  
  21. while wait() do
  22.     local magnitude = (part1.Position - part2.Position).magnitude
  23.     distance.Value = part2.Name.." is "..math.floor(magnitude).." studs away."
  24. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement