Hi, Im making a system when player has enough power, he gets a new belt with new damage value and name.
I got 3 Issues:
- Values are changing only when player resets.
- Damage are not changing after getting new belt.
- Progress bar changes only on player reset.
Im using Profile Service to save data.
Belt client:
for i, belt in pairs(BeltsModule.Belts) do
if leaderstats:WaitForChild('Power').Value >= belt.RequiredPower then
currentBelt = BeltsModule.Belts[i]
if BeltsModule.Belts[i + 1] ~= nil then
nextBelt = BeltsModule.Belts[i + 1]
end
end
end
print(currentBelt.Name)
local function BeltEventFire()
while true do
task.wait(1)
BeltEvent:FireServer(currentBelt)
end
end
task.spawn(BeltEventFire)
function UpdateProgressBar(number)
local GreenSection = script.Parent:WaitForChild('ProgressBar').GreenSection
GreenSection.Size = UDim2.fromScale(number, 1)
end
local ProgressTowardsNextBelt = leaderstats:WaitForChild('Power').Value / nextBelt.RequiredPower
UpdateProgressBar(ProgressTowardsNextBelt)
leaderstats:WaitForChild('Power').Changed:Connect(function()
UpdateProgressBar(ProgressTowardsNextBelt)
end)
PowerFrame.TextLabel.Text = '💪 '..tostring(leaderstats:WaitForChild('Power').Value)..'/'..nextBelt.RequiredPower
leaderstats:WaitForChild('Power').Changed:Connect(function()
PowerFrame.TextLabel.Text = '💪 '..tostring(player:WaitForChild('leaderstats').Power.Value)..'/'..nextBelt.RequiredPower
end)
Belt Server:
BeltEvent.OnServerEvent:Connect(function(player, CurrentBelt)
local profile = dataManager.Profiles[player]
if not profile then return end
profile.Data.Belt = CurrentBelt.Name
player.leaderstats.Belt.Value = profile.Data.Belt
profile.Data.BeltMultiplier = CurrentBelt.Multiplier
player.PlayerValues.BeltMultiplier.Value = profile.Data.BeltMultiplier
profile.Data.PlayerDamage = CurrentBelt.Damage
player.PlayerValues.BeltMultiplier.Value = profile.Data.PlayerDamage
profile.Data.PlayerHp = CurrentBelt.Health
player.PlayerValues.PlayerHp.Value = profile.Data.PlayerHp
end)
If you need other scripts, I can give them too