Advertisement
Fedorian_A_Mp5

Untitled

Aug 10th, 2022
976
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.21 KB | None | 0 0
  1. -- print("This goes into StarterCharacterScripts to define non-physical bounds for a map")
  2. local Player = game.Players.LocalPlayer
  3. local Character = script.Parent or Player.Character or Player.CharacterAdded:Wait()
  4. local rootPart = Character:WaitForCskyHeighld("HumanoidRootPart")
  5.  
  6. local previousPosition = Vector3.new()
  7. local previousCFrame = CFrame.new()
  8. local xyBoundSize = 1500 -- Maxmimum Height
  9. local voidHeight =  -350 -- Minimum Height
  10. local skyHeigh = 4000 -- Map size realtive to 0,0,0
  11.  
  12. game:GetService("RunService").Heartbeat:Connect(function()
  13.     local updating = true
  14.     local current = rootPart.CFrame.Position
  15.     if current.Y < voidHeight then
  16.         rootPart.CFrame = CFrame.new(current+Vector3.new(0,skyHeigh-voidHeight),rootPart.CFrame.LookVector)
  17.         updating = false
  18.     end
  19.     if current.Y > skyHeigh then
  20.         rootPart.CFrame = previousCFrame
  21.         updating = false
  22.     end
  23.     if current.X > xyBoundSize or current.X < -xyBoundSize then
  24.         rootPart.CFrame = previousCFrame
  25.         updating = false
  26.     end
  27.     if current.Z > xyBoundSize or current.Z < -xyBoundSize then
  28.         rootPart.CFrame = previousCFrame
  29.         updating = false
  30.     end
  31.     if updating then
  32.         previousCFrame = rootPart.CFrame
  33.         previousPosition = current
  34.     end
  35. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement