#Not working
1 messages · Page 1 of 1 (latest)
local tool = script.Parent
local player = game.Players.LocalPlayer
local maxNen = 100
local gui = player:WaitForChild("PlayerGui"):WaitForChild("NenGui")
local nenBar = gui:WaitForChild("Nen")
local nenText = gui:WaitForChild("NenText")
local nen = maxNen
local maxHeight = 95
local maxWidth = 20
local basePosX = 0.047
local basePosY = 0.396
nenBar.AnchorPoint = Vector2.new(0, 0)
nenBar.Position = UDim2.new(basePosX, 0, basePosY, maxHeight)
nenBar.Size = UDim2.new(0, maxWidth, 0, 0)
local tweenTime = 0.5
local function updateNenBar()
local ratio = nen / maxNen
local newHeight = math.floor(maxHeight * ratio)
local pixelOffset = maxHeight - newHeight
nenText.Text = tostring(math.floor(nen)) .. "%"
local sizeTween = TweenService:Create(nenBar, TweenInfo.new(tweenTime, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {
Size = UDim2.new(0, maxWidth, 0, newHeight)
})
local posTween = TweenService:Create(nenBar, TweenInfo.new(tweenTime, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {
Position = UDim2.new(basePosX, 0, basePosY, pixelOffset)
})
sizeTween:Play()
posTween:Play()
end
local increasing = false
local increaseCoroutine = nil
local function startIncreasingNen()
if increasing then return end
increasing = true
increaseCoroutine = coroutine.create(function()
while increasing and nen < maxNen do
nen = math.min(nen + 5, maxNen)
updateNenBar()
wait(0.5)
end
increasing = false
end)
coroutine.resume(increaseCoroutine)
end
local function stopIncreasingNen()
increasing = false
end
tool.Activated:Connect(function()
if nen < 100 then
startIncreasingNen()
end
end)
tool.Deactivated:Connect(function()
stopIncreasingNen()
end)
updateNenBar()```
the last few lines of code tool.Deactivated:Connect(function().. end) says that whenever you swap tools, you will stop regening
That’s the problem right there
If you swap tools/ unequip tools, Nen wont regen