Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Subscribe to SxS Scripting --
- local ManaEvent = game.ReplicatedStorage.ManaEvent
- local RunService = game:GetService("RunService")
- local Debounce = {}
- local Debounce2 = {}
- game.Players.PlayerAdded:Connect(function(Player)
- repeat wait() until Player.Character
- local DataFolder = Instance.new("Folder", Player)
- DataFolder.Name = "DataFolder"
- local MaxMana = Instance.new("NumberValue",DataFolder)
- MaxMana.Name = "MaxMana"
- MaxMana.Value = 100
- local Mana = Instance.new("NumberValue", DataFolder)
- Mana.Name = "Mana"
- Mana.Value = 0
- local FullCharge = Instance.new("NumberValue",DataFolder)
- FullCharge.Name = "FullCharge"
- FullCharge.Value = .1
- local BarDecrease = Instance.new("NumberValue",DataFolder)
- BarDecrease.Value = 10
- BarDecrease.Name = "BarDecrease"
- FullCharge.Changed:Connect(function()
- Debounce[Player] = nil
- if FullCharge.Value > 1.5 then
- FullCharge.Value = 1.5
- Debounce[Player] = nil
- end
- if BarDecrease.Value > 3 then
- BarDecrease.Value = 3
- end
- end)
- end)
- ManaEvent.OnServerEvent:Connect(function(Player, IsKeyDown)
- Debounce[Player] = IsKeyDown
- end)
- RunService.Heartbeat:Connect(function(dt)
- for _,Player in pairs(game.Players:GetPlayers()) do
- local Mana = Player:WaitForChild("DataFolder").Mana
- local MaxMana = Player.DataFolder.MaxMana
- local FullCharge = Player.DataFolder.FullCharge
- local BarDecrease = Player.DataFolder.BarDecrease
- if Debounce[Player] then
- Mana.Value = math.min(Mana.Value + FullCharge.Value * dt * 115, MaxMana.Value)
- else
- Mana.Value = (math.max(Mana.Value - FullCharge.Value * (dt *100*BarDecrease.Value),0))
- print((math.max(Mana.Value - FullCharge.Value * (dt *100*BarDecrease.Value),0)))
- --math.max(Mana.Value - FullCharge.Value * (dt * 100 +),0) [Original]
- end
- if Mana.Value == MaxMana.Value then
- if not Debounce2[Player] then
- Debounce2[Player] = true
- FullCharge.Value = FullCharge.Value + .1
- BarDecrease.Value = BarDecrease.Value - .5
- end
- else
- Debounce2[Player] = nil
- end
- local ManaGUI = Player.PlayerGui:WaitForChild("ScreenGui").BackFrame.Overlay
- ManaGUI:TweenSize(UDim2.new(1, 0,-(Mana.Value/MaxMana.Value),0), "In", "Sine", .1)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement