Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- print("This goes into StarterCharacterScripts to define non-physical bounds for a map")
- local Player = game.Players.LocalPlayer
- local Character = script.Parent or Player.Character or Player.CharacterAdded:Wait()
- local rootPart = Character:WaitForCskyHeighld("HumanoidRootPart")
- local previousPosition = Vector3.new()
- local previousCFrame = CFrame.new()
- local xyBoundSize = 1500 -- Maxmimum Height
- local voidHeight = -350 -- Minimum Height
- local skyHeigh = 4000 -- Map size realtive to 0,0,0
- game:GetService("RunService").Heartbeat:Connect(function()
- local updating = true
- local current = rootPart.CFrame.Position
- if current.Y < voidHeight then
- rootPart.CFrame = CFrame.new(current+Vector3.new(0,skyHeigh-voidHeight),rootPart.CFrame.LookVector)
- updating = false
- end
- if current.Y > skyHeigh then
- rootPart.CFrame = previousCFrame
- updating = false
- end
- if current.X > xyBoundSize or current.X < -xyBoundSize then
- rootPart.CFrame = previousCFrame
- updating = false
- end
- if current.Z > xyBoundSize or current.Z < -xyBoundSize then
- rootPart.CFrame = previousCFrame
- updating = false
- end
- if updating then
- previousCFrame = rootPart.CFrame
- previousPosition = current
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement