I am making a chakra system for fun, And I have it so when the player joins, an int value is added to them, and their chakra levels are 950.
So I have been working on a system to add chakra when the player is low on chakra so they can regain their chakra. But whenever I try to add to the players int value which holds their chakra levels, it resets to 950, Instead of adding by 1 every 0.01 seconds. I have it so when the player presses C, A local script fires an event and a server script adds to their chakra, also I have another script that holds a jutsu, and when the jutsu is used it takes the players chakra, I’m doing that on a module script.
It does add by 1 every 0.01 second BUT, that’s after it resets to 950, and it adds from there
Attempted solutions:
I have tried swapping between client and server, and when I check the player’s chakra on the server, it shows that it is low, from the jutsu the player used. I’ve also made multiple prints on a server script to see the players chakra levels
https://gyazo.com/2a94a5d4054b7d71192b0e3d489074c4
event.OnServerEvent:Connect(function(Player)
local char = workspace[Player.Name]
local humroot = char.HumanoidRootPart
local chakra = Player.Chakra
---[[[ Cloning ]]]---
print(chakra.Value)
local originvalue
originvalue = chakra.Value
if chakra.Value ~= 1000 then
local a = game.ReplicatedStorage["2"]:Clone()
local b = game.ReplicatedStorage["1"]:Clone()
a.Parent = humroot
b.Parent = humroot
local value = chakra.Value
print(value)
print(chakra.Value)
repeat wait(0.01)
originvalue = originvalue + 1
chakra.Value = originvalue
until originvalue == 950
if value == 950 then
a:Destroy()
b:Destroy()
print(chakra.Value)
end
end
end)
return module