Advertisement
SxScripting

SpiritPressure[Server Script]

Aug 26th, 2021
959
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.43 KB | None | 0 0
  1. local RS = game:GetService("ReplicatedStorage")
  2. local RunService = game:GetService("RunService")
  3. local Players = game:GetService("Players")
  4.  
  5. local RegionSize = Vector3.new(80, 22, 104)
  6. local Duration,Cooldown = 3,2
  7.  
  8. local RegionTable, V1 = {},{}
  9. local Debounce, EffectTable = {}, {}
  10. local Debonce2 = false
  11.  
  12. local plr
  13.  
  14. local function ChangeSpeed(Character,Walk,Jump,IsAnc)
  15. Character.Humanoid.WalkSpeed = Walk or 16
  16. Character.Humanoid.JumpPower = Jump or 50
  17. Character.HumanoidRootPart.Anchored = IsAnc or false
  18. end
  19.  
  20. local function OnPlayerAdded(Player)
  21. Player.CharacterAdded:Connect(function(Character)
  22. local Spirit = Instance.new("NumberValue", Character)
  23. Spirit.Value = .5
  24. Spirit.Name = "Spirit"
  25. end)
  26. end
  27.  
  28. local function SpirtRemote(Player)
  29. plr = Player
  30. if Debounce[plr] and Debonce2 then return else print(Debounce[plr], Debonce2) end
  31. local Reg1 = (Player.Character.HumanoidRootPart.CFrame).p - (RegionSize / 2)
  32. local Reg2 = (Player.Character.HumanoidRootPart.CFrame).p + (RegionSize / 2)
  33.  
  34. V1[Player] = Region3.new(Reg1,Reg2)
  35. Debounce[Player] = true
  36. end
  37.  
  38. local function SetPlayerWithMove()
  39. if not Debounce[plr] then return end
  40. local Character = plr.Character
  41. local CreateRegion = workspace:FindPartsInRegion3(V1[plr],Character,math.huge)
  42. for Index, Value in pairs(CreateRegion) do
  43. if Value.Parent:FindFirstChild("Humanoid") then
  44. local SpiritNum = Character.Spirit.Value
  45. local CharInRegion = Value.Parent
  46.  
  47. if RegionTable[CharInRegion] == CharInRegion then
  48. if RegionTable[CharInRegion].Humanoid:GetAttribute("DoneEffects") then
  49. RegionTable[CharInRegion].Humanoid:TakeDamage(SpiritNum/100000)
  50. end
  51. else
  52. RegionTable[CharInRegion] = CharInRegion
  53. RegionTable[CharInRegion].Humanoid:SetAttribute("DoneEffects",false)
  54. end
  55. end
  56. end
  57.  
  58. for Index,v in pairs(RegionTable) do
  59. if v.Humanoid:GetAttribute("DoneEffects") then return end
  60. if Debonce2 then return end
  61. if v == Character then
  62. RegionTable[Index] = nil
  63. continue
  64. end
  65. if v.Spirit.Value > Character.Spirit.Value then continue end
  66. local Humanoid = v.Humanoid
  67. local Effects = game.ReplicatedStorage.Effects:Clone()
  68.  
  69. local NewAnimation = Instance.new("Animation");
  70. NewAnimation.AnimationId = "rbxassetid://7277996242"
  71. local KneelDown = Humanoid:LoadAnimation(NewAnimation)
  72. ChangeSpeed(v,0,0,true)
  73. for _,Emit in pairs(Effects:GetChildren()) do
  74. if Emit:IsA("ParticleEmitter") then
  75. Emit.Parent = v.Head
  76. EffectTable[#EffectTable + 1] = Emit
  77. elseif Emit:IsA("Sky") and game.Players:GetPlayerFromCharacter(v) then
  78. RS.Events.Pressure:FireClient(game.Players:GetPlayerFromCharacter(v),Duration, plr)
  79. end
  80. end
  81. EffectTable[#EffectTable + 1] = KneelDown
  82. EffectTable[#EffectTable]:Play()
  83. v.Humanoid:SetAttribute("DoneEffects", true)
  84. end
  85.  
  86. task.delay(Duration, function()
  87. if Debonce2 then return end
  88. Debonce2 = true
  89. for Index,Key in pairs(EffectTable) do
  90. if EffectTable[Index]:IsA("AnimationTrack") then EffectTable[Index]:Stop() end
  91. EffectTable[Index]:Destroy()
  92. EffectTable[Index] = nil
  93. end
  94. for i,v in pairs(RegionTable) do
  95. v.Humanoid:SetAttribute("DoneEffects", nil)
  96. ChangeSpeed(v)
  97. RegionTable[i] = nil
  98. end
  99. task.wait(Cooldown)
  100. Debounce[plr] = nil
  101. Debonce2 = false
  102. end)
  103. end
  104.  
  105. Players.PlayerAdded:Connect(OnPlayerAdded)
  106. RS.Events.Pressure.OnServerEvent:Connect(SpirtRemote)
  107. RunService.Heartbeat:Connect(SetPlayerWithMove)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement