Advertisement
Guest User

Teleport Script

a guest
Mar 23rd, 2019
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. modelname="Telepad1"---Model to telport too
  2.  
  3.  
  4. function onTouched(part)
  5. if part.Parent ~= nil then
  6. local h = part.Parent:findFirstChild("Humanoid")
  7. if h~=nil then
  8. local teleportfrom=script.Parent.Enabled.Value
  9. if teleportfrom~=0 then
  10. if h==humanoid then
  11. return
  12. end
  13. local teleportto=script.Parent.Parent:findFirstChild(modelname)
  14. if teleportto~=nil then
  15. local torso = h.Parent.Torso
  16. local location = {teleportto.Position}
  17. local i = 1
  18.  
  19. local x = location[i].x
  20. local y = location[i].y
  21. local z = location[i].z
  22.  
  23. x = x + math.random(-1, 1)
  24. z = z + math.random(-1, 1)
  25. y = y + math.random(2, 3)
  26.  
  27. local cf = torso.CFrame
  28. local lx = 0
  29. local ly = y
  30. local lz = 0
  31.  
  32. script.Parent.Enabled.Value=0
  33. teleportto.Enabled.Value=0
  34. torso.CFrame = CFrame.new(Vector3.new(x,y,z), Vector3.new(lx,ly,lz))
  35. wait(3)
  36. script.Parent.Enabled.Value=1
  37. teleportto.Enabled.Value=1
  38. else
  39. print("Could not find teleporter!")
  40. end
  41. end
  42. end
  43. end
  44. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement