Advertisement
SxScripting

RogueMana Server Script

Mar 22nd, 2021
859
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. -- Subscribe to SxS Scripting --
  2.  
  3. local ManaEvent = game.ReplicatedStorage.ManaEvent
  4. local RunService = game:GetService("RunService")
  5. local Debounce = {}
  6. local Debounce2 = {}
  7.  
  8. game.Players.PlayerAdded:Connect(function(Player)
  9. repeat wait() until Player.Character
  10.  
  11. local DataFolder = Instance.new("Folder", Player)
  12. DataFolder.Name = "DataFolder"
  13.  
  14. local MaxMana = Instance.new("NumberValue",DataFolder)
  15. MaxMana.Name = "MaxMana"
  16. MaxMana.Value = 100
  17.  
  18. local Mana = Instance.new("NumberValue", DataFolder)
  19. Mana.Name = "Mana"
  20. Mana.Value = 0
  21.  
  22. local FullCharge = Instance.new("NumberValue",DataFolder)
  23. FullCharge.Name = "FullCharge"
  24. FullCharge.Value = .1
  25.  
  26. local BarDecrease = Instance.new("NumberValue",DataFolder)
  27. BarDecrease.Value = 10
  28. BarDecrease.Name = "BarDecrease"
  29.  
  30. FullCharge.Changed:Connect(function()
  31. Debounce[Player] = nil
  32. if FullCharge.Value > 1.5 then
  33. FullCharge.Value = 1.5
  34. Debounce[Player] = nil
  35. end
  36.  
  37. if BarDecrease.Value > 3 then
  38. BarDecrease.Value = 3
  39. end
  40. end)
  41.  
  42. end)
  43.  
  44. ManaEvent.OnServerEvent:Connect(function(Player, IsKeyDown)
  45. Debounce[Player] = IsKeyDown
  46. end)
  47.  
  48. RunService.Heartbeat:Connect(function(dt)
  49. for _,Player in pairs(game.Players:GetPlayers()) do
  50. local Mana = Player:WaitForChild("DataFolder").Mana
  51. local MaxMana = Player.DataFolder.MaxMana
  52. local FullCharge = Player.DataFolder.FullCharge
  53. local BarDecrease = Player.DataFolder.BarDecrease
  54.  
  55. if Debounce[Player] then
  56. Mana.Value = math.min(Mana.Value + FullCharge.Value * dt * 115, MaxMana.Value)
  57. else
  58. Mana.Value = (math.max(Mana.Value - FullCharge.Value * (dt *100*BarDecrease.Value),0))
  59. print((math.max(Mana.Value - FullCharge.Value * (dt *100*BarDecrease.Value),0)))
  60. --math.max(Mana.Value - FullCharge.Value * (dt * 100 +),0) [Original]
  61. end
  62. if Mana.Value == MaxMana.Value then
  63. if not Debounce2[Player] then
  64. Debounce2[Player] = true
  65. FullCharge.Value = FullCharge.Value + .1
  66. BarDecrease.Value = BarDecrease.Value - .5
  67. end
  68. else
  69. Debounce2[Player] = nil
  70. end
  71. local ManaGUI = Player.PlayerGui:WaitForChild("ScreenGui").BackFrame.Overlay
  72. ManaGUI:TweenSize(UDim2.new(1, 0,-(Mana.Value/MaxMana.Value),0), "In", "Sine", .1)
  73. end
  74. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement