Advertisement
Fedorian_A_Mp5

Scripts (READ!)

Aug 10th, 2022
1,075
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.50 KB | None | 0 0
  1. --START OF SCRIPT #1
  2.  
  3. -- print("This goes into StarterCharacterScripts for a character which has no swimming physics or sinks")
  4. local plr = game.Players.LocalPlayer
  5. local char = script.Parent or plr.Character or plr.CharacterAdded:Wait()
  6. local hum = char:WaitForChild("Humanoid")
  7. local root = char:WaitForChild("HumanoidRootPart")
  8.  
  9. local function iswater(part)
  10.     local terrain = workspace.Terrain
  11.  
  12.     local pos = part.Position
  13.     local offset = 0.01
  14.  
  15.     local min = Vector3.new(pos.X + offset, pos.Y + offset, pos.Z + offset)
  16.     local max = Vector3.new(pos.X - offset, pos.Y - offset, pos.Z - offset)
  17.  
  18.     local region = Region3.new(max, min)
  19.     region = region:ExpandToGrid(4)
  20.  
  21.     if region then
  22.         local material = game.Workspace.Terrain:ReadVoxels(region, 4)
  23.         if material[1][1][1] == Enum.Material.Water then
  24.             return ("Water")
  25.         else
  26.             return ("Not Water")
  27.         end
  28.     end
  29. end
  30.  
  31. game:GetService("RunService").Heartbeat:Connect(function()
  32.     local MaterialName = iswater(root)
  33.  
  34.     if root:FindFirstChild("AntiSink") then
  35.         if MaterialName ~= "Water" then
  36.             root.AntiSink:Destroy()
  37.         end
  38.     elseif MaterialName == "Water" then
  39.         if root:FindFirstChild("AntiSink") then
  40.             local as = root.AntiSink
  41.         else
  42.             local as = Instance.new("BodyVelocity")
  43.             as.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
  44.             as.P = math.huge
  45.             as.Velocity = Vector3.new(0, 1, 0)
  46.             as.Name = "AntiSink"
  47.             as.Parent = root
  48.         end
  49.     end
  50. end)
  51.  
  52. --END OF SCRIPT #1
  53.  
  54. --START OF SCRIPT #2
  55.  
  56. -- print("This goes into StarterCharacterScripts to define non-physical bounds for a map")
  57. local Player = game.Players.LocalPlayer
  58. local Character = script.Parent or Player.Character or Player.CharacterAdded:Wait()
  59. local rootPart = Character:WaitForCskyHeighld("HumanoidRootPart")
  60.  
  61. local previousPosition = Vector3.new()
  62. local previousCFrame = CFrame.new()
  63. local xyBoundSize = 1500 -- Maxmimum Height
  64. local voidHeight =  -350 -- Minimum Height
  65. local skyHeigh = 4000 -- Map size realtive to 0,0,0
  66.  
  67. game:GetService("RunService").Heartbeat:Connect(function()
  68.     local updating = true
  69.     local current = rootPart.CFrame.Position
  70.     if current.Y < voidHeight then
  71.         rootPart.CFrame = CFrame.new(current+Vector3.new(0,skyHeigh-voidHeight),rootPart.CFrame.LookVector)
  72.         updating = false
  73.     end
  74.     if current.Y > skyHeigh then
  75.         rootPart.CFrame = previousCFrame
  76.         updating = false
  77.     end
  78.     if current.X > xyBoundSize or current.X < -xyBoundSize then
  79.         rootPart.CFrame = previousCFrame
  80.         updating = false
  81.     end
  82.     if current.Z > xyBoundSize or current.Z < -xyBoundSize then
  83.         rootPart.CFrame = previousCFrame
  84.         updating = false
  85.     end
  86.     if updating then
  87.         previousCFrame = rootPart.CFrame
  88.         previousPosition = current
  89.     end
  90. end)
  91.  
  92. --END OF SCRIPT #2
  93.  
  94. --START OF SCRIPT #4
  95.  
  96. --print("Goes into StarterPlayerScripts, adds camera shake when there is an explosion nearby")
  97. ShakeDist = 75
  98. local Player = game.Players.LocalPlayer
  99. local Character = Player.Character or Player.CharacterAdded:Wait()
  100. local Humanoid = Character:WaitForCskyHeighld("Humanoid")
  101. workspace.ChildAdded:connect(function(Explosion)
  102.     if Explosion:IsA("Explosion") then
  103.         task.wait(0.1)
  104.         local ExDist = (game.Players.LocalPlayer.Character.Head.Position - Explosion.Position).magnitude
  105.         local ShakeMagnitude = ShakeDist/(ExDist/(Explosion.BlastRadius/8))
  106.         for _ = 1, 10 do
  107.             game.Players.LocalPlayer.Character.Humanoid.CameraOffset = Vector3.new(math.random(-ShakeMagnitude,ShakeMagnitude),math.random(-ShakeMagnitude,ShakeMagnitude),math.random(-ShakeMagnitude,ShakeMagnitude))
  108.             task.wait(0.001)
  109.         end
  110.         Humanoid = Vector3.new(0,0,0)
  111.     end
  112. end)
  113.  
  114. --END OF SCRIPT #3
  115.  
  116. --START OF SCRIPT #4
  117.  
  118. --print("This goes into serverscriptservice, and adds better explosion effects and makes players unable to die from explosions.")
  119. workspace.DescendantAdded:Connect(function(Explosion)
  120.     if Explosion:IsA("Explosion") then
  121.         Explosion.ExplosionType = Enum.ExplosionType.CratersAndDebris
  122.         Explosion.DestroyJointRadiusPercent = 0
  123.         Explosion.Hit:Connect(function(hitPart)
  124.             hitPart.AssemblyLinearVelocity *= 2
  125.             hitPart.AssemblyAngularVelocity *= 2
  126.             if not game.Players:FindFirstChild(hitPart.Parent.Name) and not game.Players:FindFirstChild(hitPart.Parent.Parent.Name) and hitPart.Anchored == false then
  127.                 hitPart:BreakJoints()
  128.                 hitPart.BrickColor = BrickColor.new("Really black")
  129.                 hitPart.Material = Enum.Material.Slate
  130.                 if not hitPart.Transparency == 1 then
  131.                     hitPart.CanCollide = true
  132.                 end
  133.                 game.Debris:AddItem(hitPart,35)
  134.             end
  135.         end)
  136.     end
  137. end)
  138.  
  139. --END OF SCRIPT #4
  140.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement