So sometimes it’s weird my datasaving aren’t working properly but sometimes it does when I kill a player it increase the value by 1 on leaderstats but when I love sometimes it saves perfectly the data and sometimes it doesn’t. Also when there’s data teleportation the saving also doesn’t work when I transfer from Place A to Place B. Here’s the code of the datasaving :
local onJoinTable = {
--If true, then no data is set up.
[true] = function(player, result)
print("No data was found, player joined for the first time");
local playerClass = require(script.PlayerClass).new(player);
playerClasses[ps:GetUserIdFromNameAsync(player.Name)] = playerClass;
for i, v in pairs(listOfPlayerToBan) do
if player.Name == v then
player:Kick("You've been forever banned from the game.")
end
end
CurrentPlayer = game.Workspace:FindFirstChild(tostring(player))
CurrentPlayer.Punch.Disabled = true
CurrentPlayer.Block.Disabled = true
ReplicatedStorage.CameraAction.PlayerPressedPlay.OnServerEvent:Connect(function(player)
ReplicatedStorage.CameraAction.SkinCharacterCamera:FireClient(player)
end)
BadgeService:AwardBadge(player.UserId, WelcomeBadgeId)
local PlayerModel = game.Workspace:FindFirstChild(player.Name)
PlayerModel:ScaleTo(player:WaitForChild("Height").Value)
local AnimationsFolder = player:WaitForChild("DefaultAnimations")
local rightPunchAnimationId = Instance.new("IntValue", AnimationsFolder)
rightPunchAnimationId.Name = "RightPunch"
rightPunchAnimationId.Value = 16020955031
local leftPunchAnimationId = Instance.new("IntValue", AnimationsFolder)
leftPunchAnimationId.Name = "LeftPunch"
leftPunchAnimationId.Value = 16021081080
player:WaitForChild("NumberConnexion").Value += 1
print(playerClass);
task.wait(3);
print(playerClass);
end,
-- If false, data exists and we can load data
[false] = function(player, result)
resultStored = result
print("Player data was found, loading data.");
for i, v in pairs(listOfPlayerToBan) do
if player.Name == v then
player:Kick("You've been forever banned from the game.")
end
end
local playerClass = require(script.PlayerClass).new(player, http:JSONDecode(result));
playerClass:setCharacter(player.Character);
playerClass:setName(player.Name);
playerClasses[ps:GetUserIdFromNameAsync(player.Name)] = playerClass;
player:WaitForChild("Height").Value = playerClass.height
if playerClass.gender == "Female" then
local cloneWoman = game.Workspace.FEMALELOCKERROOM:Clone()
cloneWoman.Name = "StarterCharacter"
cloneWoman.Parent = game.StarterPlayer
player:LoadCharacter()
local PlayerModel = game.Workspace:FindFirstChild(player.Name)
PlayerModel:ScaleTo(player:WaitForChild("Height").Value)
player.Character.Humanoid.WalkSpeed = 16 + (player:WaitForChild("CharStats").Speed.Value * HUMANOID_WALK_SPEED_MULTIPLIER)
player.Character.Humanoid.MaxHealth = 50 + (player:WaitForChild("CharStats").Health.Value * HEALTH_LEVEL_MULTIPLIER)
player.Character.Humanoid.Health = player.Character.Humanoid.MaxHealth
elseif playerClass.gender == "Male" then
local cloneMan = game.Workspace.MALELOCKERROOM:Clone()
cloneMan.Name = "StarterCharacter"
cloneMan.Parent = game.StarterPlayer
player:LoadCharacter()
local PlayerModel = game.Workspace:FindFirstChild(player.Name)
PlayerModel:ScaleTo(player:WaitForChild("Height").Value)
player.Character.Humanoid.WalkSpeed = 16 + (player:WaitForChild("CharStats").Speed.Value * HUMANOID_WALK_SPEED_MULTIPLIER)
player.Character.Humanoid.MaxHealth = 50 + (player:WaitForChild("CharStats").Health.Value * HEALTH_LEVEL_MULTIPLIER)
player.Character.Humanoid.Health = player.Character.Humanoid.MaxHealth
end
player:WaitForChild("leaderstats").Power.Value = playerClass.power
player:WaitForChild("leaderstats").Rebirth.Value = playerClass.rebirth
player:WaitForChild("RebirthTotalMultiplier").Value = playerClass.rebirthtotalmultiplier
player:WaitForChild("leaderstats").Kill.Value = playerClass.kill
if player:GetJoinData().TeleportData then
player:WaitForChild("leaderstats").Wins.Value = player:GetJoinData().TeleportData.wins
player:WaitForChild("BodybuildingExp").Value = player:GetJoinData().TeleportData.musclemassexp
player:WaitForChild("HealthDiscipline").HealthExp.Value = player:GetJoinData().TeleportData.healthexp
player:WaitForChild("StrengthDiscipline").StrengthExp.Value = player:GetJoinData().TeleportData.strengthexp
player:WaitForChild("ResistanceDiscipline").ResistanceExp.Value = player:GetJoinData().TeleportData.resistanceexp
player:WaitForChild("SpeedDiscipline").SpeedExp.Value = player:GetJoinData().TeleportData.speedexp
else
player:WaitForChild("leaderstats").Wins.Value = playerClass.wins
player:WaitForChild("BodybuildingExp").Value = playerClass.bodybuildingexp
player:WaitForChild("HealthDiscipline").HealthExp.Value = playerClass.calisthenicsexp
player:WaitForChild("StrengthDiscipline").StrengthExp.Value = playerClass.powerliftingsexp
player:WaitForChild("ResistanceDiscipline").ResistanceExp.Value = playerClass.fightingsexp
player:WaitForChild("SpeedDiscipline").SpeedExp.Value = playerClass.runningsexp
end
player:WaitForChild("NumberConnexion").Value = playerClass.numberconnexion
player:WaitForChild("CharStats").MuscleMass.Value = playerClass.musclemass
player:WaitForChild("CharStats").Health.Value = playerClass.health
player:WaitForChild("CharStats").Strength.Value = playerClass.strength
player:WaitForChild("CharStats").Resistance.Value = playerClass.resistance
player:WaitForChild("CharStats").Speed.Value = playerClass.speed
player:WaitForChild("LapsDoneTurf").Value = playerClass.lapsdoneturf
--[[if playerClass.power >= MAXIMUM_POWER_FOR_GYM_2 then
local success, result = pcall(teleportService.TeleportAsync, teleportService, 15619812440, {player})
end]]
player:WaitForChild("DisciplineCharStats").Bodybuilding.Value = playerClass.bodybuilding
player:WaitForChild("DisciplineCharStats").Calisthenic.Value = playerClass.calisthenics
player:WaitForChild("DisciplineCharStats").PowerLifting.Value = playerClass.powerlifting
player:WaitForChild("DisciplineCharStats").Fighting.Value = playerClass.fighting
player:WaitForChild("DisciplineCharStats").Running.Value = playerClass.running
player:WaitForChild("BodybuildingExpMax").Value = playerClass.bodybuildingexpmax
player:WaitForChild("BodybuildingExpMin").Value = playerClass.bodybuildingexpmin
player:WaitForChild("HealthDiscipline").HealthExpMax.Value = playerClass.calisthenicsexpmax
player:WaitForChild("HealthDiscipline").HealthExpMin.Value = playerClass.calisthenicsexpmin
player:WaitForChild("StrengthDiscipline").StrengthExpMax.Value = playerClass.powerliftingexpmax
player:WaitForChild("StrengthDiscipline").StrengthExpMin.Value = playerClass.powerliftingexpmin
player:WaitForChild("ResistanceDiscipline").ResistanceExpMax.Value = playerClass.fightingexpmax
player:WaitForChild("ResistanceDiscipline").ResistanceExpMin.Value = playerClass.fightingexpmin
player:WaitForChild("SpeedDiscipline").SpeedExpMax.Value = playerClass.runningexpmax
player:WaitForChild("SpeedDiscipline").SpeedExpMin.Value = playerClass.runningexpmin
player:WaitForChild("WeightsInfoBench").TotalWeight.Value = playerClass.totalweight
player:WaitForChild("WeightsInfoBench").TotalWeightLimit.Value = playerClass.totalweightlimit
player:WaitForChild("WeightsInfoBench").Number25Kg.Value = playerClass.number25kg
player:WaitForChild("WeightsInfoBarcurl").TotalWeight.Value = playerClass.barcurltotalweight
player:WaitForChild("WeightsInfoBarcurl").TotalWeightLimit.Value = playerClass.barcurltotalweightlimit
player:WaitForChild("WeightsInfoBarcurl").Number25Kg.Value = playerClass.barcurlnumber25kg
player:WaitForChild("TurfWeights").TotalWeight.Value = playerClass.turftotalweight
player:WaitForChild("TurfWeights").TotalWeightLimit.Value = playerClass.turftotalweightlimit
player:WaitForChild("TurfWeights").WeightSet.Value = playerClass.turfweightset
player:WaitForChild("TurfWeights").Number25Kg.Value = playerClass.turfnumber25kg
player:WaitForChild("WeightsInfoDumbell").TotalWeight.Value = playerClass.dumbellstotalweight
player:WaitForChild("WeightsInfoDumbell").TotalWeightLimit.Value = playerClass.dumbellstotalweightlimit
player:WaitForChild("WeightsInfoDumbell").Number5Kg.Value = playerClass.dumbellsnumber5kg
player:WaitForChild("WeightsInfoDeadlift").TotalWeight.Value = playerClass.deadlifttotalweight
player:WaitForChild("WeightsInfoDeadlift").TotalWeightLimit.Value = playerClass.deadlifttotalweightlimit
player:WaitForChild("WeightsInfoDeadlift").Number25Kg.Value = playerClass.deadliftnumber25kg
player:WaitForChild("WeightsPack").OwnBronze.Value = playerClass.ownbronze
player:WaitForChild("WeightsPack").OwnSilver.Value = playerClass.ownsilver
player:WaitForChild("WeightsPack").OwnGold.Value = playerClass.owngold
player:WaitForChild("WeightsPack").OwnDiamond.Value = playerClass.owndiamond
player:WaitForChild("WeightsPack").OwnEmerald.Value = playerClass.ownemerald
player:WaitForChild("WheyPack").ForbiddenWheyAmount.Value = playerClass.forbiddenwheyamount
player:WaitForChild("WheyPack").DivineWheyAmount.Value = playerClass.divinewheyamount
player:WaitForChild("WheyPack").LegendaryWheyAmount.Value = playerClass.legendarywheyamount
player:WaitForChild("WheyPack").EpicWheyAmount.Value = playerClass.epicwheyamount
player:WaitForChild("WheyPack").RareWheyAmount.Value = playerClass.rarewheyamount
player:WaitForChild("WheyPack").UncommonWheyAmount.Value = playerClass.uncommonwheyamount
player:WaitForChild("WheyPack").StandardWheyAmount.Value = playerClass.standardwheyamount
player:WaitForChild("ClickCounter").Value = playerClass.clickcounter
player:WaitForChild("Gender").Value = playerClass.gender
CurrentPlayer = game.Workspace:WaitForChild(player.Name)
print("PLAYER GENDER IS : " .. player:WaitForChild("Gender").Value)
local AnimationIdFolder = player:WaitForChild("DefaultAnimations")
if playerClass.animationscharactersid ~= nil then
for i, v in ipairs(playerClass.animationscharactersid) do
if playerClass.animationscharactersname[i] ~= nil then
local punchAnimation = Instance.new("IntValue", AnimationIdFolder)
punchAnimation.Name = playerClass.animationscharactersname[i]
punchAnimation.Value = v
end
end
end
local turfWeights = game.Workspace.WeightsWorkout.WeightsTurf:FindFirstChild(player.Name):WaitForChild("Weights")
local turfWeightsPlayer = player:WaitForChild("WeightsTurf").Weights
if playerClass.turfweights ~= nil then
for i, v in ipairs(playerClass.turfweights) do
local weight = game.Workspace.WeightsStack:FindFirstChild(tostring(v)):Clone()
local weightPlayer = game.Workspace.WeightsStack:FindFirstChild(tostring(v)):Clone()
weight.Parent = turfWeights
weightPlayer.Parent = turfWeightsPlayer
end
end
end,
};
local playerClassDB = dss:GetDataStore("_playerClassData5332");
--local playerClassDB = dss:GetDataStore("_playerClassData5330");
-- FUNCTIONS --
function playerJoined(player)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local winsStat = Instance.new("IntValue", leaderstats)
winsStat.Name = "Wins"
winsStat.Value = 0
local Power = Instance.new("IntValue", leaderstats)
Power.Name = "Power"
Power.Value = 0
local Kill = Instance.new("IntValue", leaderstats)
Kill.Name = "Kill"
Kill.Value = 0
local Rebirth = Instance.new("NumberValue", leaderstats)
Rebirth.Name = "Rebirth"
Rebirth.Value = 0.0
local NumberConnexion = Instance.new("IntValue", player)
NumberConnexion.Name = "NumberConnexion"
NumberConnexion.Value = 0
local weightsTurfPlayer = Instance.new("Folder", workspace.WeightsWorkout.WeightsTurf)
weightsTurfPlayer.Name = player.Name
local folderTurf = Instance.new("Folder", workspace.Workouts)
folderTurf.Name = player.Name
local weightsTurf = Instance.new("Folder", weightsTurfPlayer)
weightsTurf.Name = "Weights"
local weightsBenchPlayer = Instance.new("Folder", workspace.WeightsWorkout.WeightsBench)
weightsBenchPlayer.Name = player.Name
local weightsLeft = Instance.new("Folder", weightsBenchPlayer)
weightsLeft.Name = "WeightsLeft"
local weightsRight = Instance.new("Folder", weightsBenchPlayer)
weightsRight.Name = "WeightsRight"
local weightsDeadliftPlayer = Instance.new("Folder", workspace.WeightsWorkout.WeightsDeadlift)
weightsDeadliftPlayer.Name = player.Name
local deadliftWeightsLeft = Instance.new("Folder", weightsDeadliftPlayer)
deadliftWeightsLeft.Name = "WeightsLeft"
local deadliftWeightsRight = Instance.new("Folder", weightsDeadliftPlayer)
deadliftWeightsRight.Name = "WeightsRight"
local weightsBarCurlPlayer = Instance.new("Folder", workspace.WeightsWorkout.WeightsBarCurl)
weightsBarCurlPlayer.Name = player.Name
local barCurlWeightsLeft = Instance.new("Folder", weightsBarCurlPlayer)
barCurlWeightsLeft.Name = "WeightsLeft"
local barCurlWeightsRight = Instance.new("Folder", weightsBarCurlPlayer)
barCurlWeightsRight.Name = "WeightsRight"
local weightsDumbellsPlayer = Instance.new("Folder", workspace.WeightsWorkout.WeightsDumbells)
weightsDumbellsPlayer.Name = player.Name
local weightsDumbell1 = Instance.new("Folder", weightsDumbellsPlayer)
weightsDumbell1.Name = "Dumbell1"
local weightsDumbell1WeightsLeft = Instance.new("Folder", weightsDumbell1)
weightsDumbell1WeightsLeft.Name = "WeightsLeft"
local weightsDumbell1WeightsRight = Instance.new("Folder", weightsDumbell1)
weightsDumbell1WeightsRight.Name = "WeightsRight"
local weightsDumbell2 = Instance.new("Folder", weightsDumbellsPlayer)
weightsDumbell2.Name = "Dumbell2"
local weightsDumbell2WeightsLeft = Instance.new("Folder", weightsDumbell2)
weightsDumbell2WeightsLeft.Name = "WeightsLeft"
local weightsDumbell2WeightsRight = Instance.new("Folder", weightsDumbell2)
weightsDumbell2WeightsRight.Name = "WeightsRight"
local ClickCounter = Instance.new("IntValue", player)
ClickCounter.Name = "ClickCounter"
ClickCounter.Value = 0
local LapsDoneTurf = Instance.new("IntValue", player)
LapsDoneTurf.Name = "LapsDoneTurf"
LapsDoneTurf.Value = 0
local Gender = Instance.new("StringValue", player)
Gender.Name = "Gender"
Gender.Value = "Prefered not to say"
local RebirthTotalMultiplier = Instance.new("NumberValue", player)
RebirthTotalMultiplier.Name = "RebirthTotalMultiplier"
RebirthTotalMultiplier.Value = 0.0
local charStats = Instance.new("Folder", player)
charStats.Name = "CharStats"
local healthDiscipline = Instance.new("Folder", player)
healthDiscipline.Name = "HealthDiscipline"
local expHealth = Instance.new("NumberValue", healthDiscipline)
expHealth.Name = "HealthExp"
expHealth.Value = 0
local expHealthMin = Instance.new("NumberValue", healthDiscipline)
expHealthMin.Name = "HealthExpMin"
expHealthMin.Value = 5000
local expHealthMax = Instance.new("NumberValue", healthDiscipline)
expHealthMax.Name = "HealthExpMax"
expHealthMax.Value = 5020
local speedDiscipline = Instance.new("Folder", player)
speedDiscipline.Name = "SpeedDiscipline"
local expSpeed = Instance.new("NumberValue", speedDiscipline)
expSpeed.Name = "SpeedExp"
expSpeed.Value = 0
local expSpeedMin = Instance.new("NumberValue", speedDiscipline)
expSpeedMin.Name = "SpeedExpMin"
expSpeedMin.Value = 5000
local expSpeedMax = Instance.new("NumberValue", speedDiscipline)
expSpeedMax.Name = "SpeedExpMax"
expSpeedMax.Value = 5020
local strengthDiscipline = Instance.new("Folder", player)
strengthDiscipline.Name = "StrengthDiscipline"
local expStrength = Instance.new("NumberValue", strengthDiscipline)
expStrength.Name = "StrengthExp"
expStrength.Value = 0
local expStrengthMin = Instance.new("NumberValue", strengthDiscipline)
expStrengthMin.Name = "StrengthExpMin"
expStrengthMin.Value = 5000
local expStrengthMax = Instance.new("NumberValue", strengthDiscipline)
expStrengthMax.Name = "StrengthExpMax"
expStrengthMax.Value = 5020
local resistanceDiscipline = Instance.new("Folder", player)
resistanceDiscipline.Name = "ResistanceDiscipline"
local expResistance = Instance.new("NumberValue", resistanceDiscipline)
expResistance.Name = "ResistanceExp"
expResistance.Value = 0
local expResistanceMin = Instance.new("NumberValue", resistanceDiscipline)
expResistanceMin.Name = "ResistanceExpMin"
expResistanceMin.Value = 5000
local expResistanceMax = Instance.new("NumberValue", resistanceDiscipline)
expResistanceMax.Name = "ResistanceExpMax"
expResistanceMax.Value = 5020
local disciplineCharStats = Instance.new("Folder", player)
disciplineCharStats.Name = "DisciplineCharStats"
local expBodyBuilding = Instance.new("NumberValue", player)
expBodyBuilding.Name = "BodybuildingExp"
expBodyBuilding.Value = 0
local expBodyBuildingMin = Instance.new("NumberValue", player)
expBodyBuildingMin.Name = "BodybuildingExpMin"
expBodyBuildingMin.Value = 5000
local expBodyBuildingMax = Instance.new("NumberValue", player)
expBodyBuildingMax.Name = "BodybuildingExpMax"
expBodyBuildingMax.Value = 5020
--stats
local strengthStat = Instance.new("NumberValue", charStats)
strengthStat.Name = "Strength"
strengthStat.Value = 0
local speedStat = Instance.new("NumberValue", charStats)
speedStat.Name = "Speed"
speedStat.Value = 0
local muscleMassStat = Instance.new("NumberValue", charStats)
muscleMassStat.Name = "MuscleMass"
muscleMassStat.Value = 0
local resistanceStat = Instance.new("NumberValue", charStats)
resistanceStat.Name = "Resistance"
resistanceStat.Value = 0
local healthStat = Instance.new("NumberValue", charStats)
healthStat.Name = "Health"
healthStat.Value = 0
local bodyBuildingLevel = Instance.new("NumberValue", disciplineCharStats)
bodyBuildingLevel.Name = "Bodybuilding"
bodyBuildingLevel.Value = 0
local runningLevel = Instance.new("NumberValue", disciplineCharStats)
runningLevel.Name = "Running"
runningLevel.Value = 0
local powerLiftingLevel = Instance.new("NumberValue", disciplineCharStats)
powerLiftingLevel.Name = "PowerLifting"
powerLiftingLevel.Value = 0
local calisthenicLevel = Instance.new("NumberValue", disciplineCharStats)
calisthenicLevel.Name = "Calisthenic"
calisthenicLevel.Value = 0
local fightingLevel = Instance.new("NumberValue", disciplineCharStats)
fightingLevel.Name = "Fighting"
fightingLevel.Value = 0
--end of stats
local characterHeight = Instance.new("NumberValue", player)
characterHeight.Name = "Height"
characterHeight.Value = 0.7
local characterPunchingStrength = Instance.new("IntValue", player)
characterPunchingStrength.Name = "Punch"
characterPunchingStrength.Value = 0.2
local weightsBench = Instance.new("Folder", player)
weightsBench.Name = "WeightsBench"
local weightsBenchRight = Instance.new("Folder", weightsBench)
weightsBenchRight.Name = "WeightsRight"
local weightsBenchLeft = Instance.new("Folder", weightsBench)
weightsBenchLeft.Name = "WeightsLeft"
local weightsDeadliftFolderInPlayer = Instance.new("Folder", player)
weightsDeadliftFolderInPlayer.Name = "WeightsDeadlift"
local weightFolderRightDeadlift = Instance.new("Folder", weightsDeadliftFolderInPlayer)
weightFolderRightDeadlift.Name = "WeightsRight"
local weightFolderLeftDeadlift = Instance.new("Folder", weightsDeadliftFolderInPlayer)
weightFolderLeftDeadlift.Name = "WeightsLeft"
local weightsBarCurl = Instance.new("Folder", player)
weightsBarCurl.Name = "WeightsBarCurl"
local weightsBarCurlRight = Instance.new("Folder", weightsBarCurl)
weightsBarCurlRight.Name = "WeightsRight"
local weightsBarCurlLeft = Instance.new("Folder", weightsBarCurl)
weightsBarCurlLeft.Name = "WeightsLeft"
local weightsDumbellsInPlayer = Instance.new("Folder", player)
weightsDumbellsInPlayer.Name = "WeightsDumbells"
local weightsDumbell1InPlayer = Instance.new("Folder", weightsDumbellsInPlayer)
weightsDumbell1InPlayer.Name = "Dumbell1"
local weightsDumbell1WeightsLeftInPlayer = Instance.new("Folder", weightsDumbell1InPlayer)
weightsDumbell1WeightsLeftInPlayer.Name = "WeightsLeft"
local weightsDumbell1WeightsRightInPlayer = Instance.new("Folder", weightsDumbell1InPlayer)
weightsDumbell1WeightsRightInPlayer.Name = "WeightsRight"
local weightsDumbell2InPlayer = Instance.new("Folder", weightsDumbellsInPlayer)
weightsDumbell2InPlayer.Name = "Dumbell2"
local weightsDumbell2WeightsLeftInPlayer = Instance.new("Folder", weightsDumbell2InPlayer)
weightsDumbell2WeightsLeftInPlayer.Name = "WeightsLeft"
local weightsDumbell2WeightsRightInPlayer = Instance.new("Folder", weightsDumbell2InPlayer)
weightsDumbell2WeightsRightInPlayer.Name = "WeightsRight"
local WeightsStatsBench = Instance.new("Folder", player)
WeightsStatsBench.Name = "WeightsInfoBench"
local number25Kg = Instance.new("IntValue", WeightsStatsBench)
number25Kg.Name = "Number25Kg"
number25Kg.Value = 0
local totalWeight = Instance.new("NumberValue", WeightsStatsBench)
totalWeight.Name = "TotalWeight"
totalWeight.Value = 0.0
local totalWeightLimit = Instance.new("NumberValue", WeightsStatsBench)
totalWeightLimit.Name = "TotalWeightLimit"
totalWeightLimit.Value = 0.0
local WeightsStatsDeadlift = Instance.new("Folder", player)
WeightsStatsDeadlift.Name = "WeightsInfoDeadlift"
local number25KgDeadlift = Instance.new("IntValue", WeightsStatsDeadlift)
number25KgDeadlift.Name = "Number25Kg"
number25KgDeadlift.Value = 0
local totalWeightDeadlift = Instance.new("NumberValue", WeightsStatsDeadlift)
totalWeightDeadlift.Name = "TotalWeight"
totalWeightDeadlift.Value = 0.0
local totalWeightLimitDeadlift = Instance.new("NumberValue", WeightsStatsDeadlift)
totalWeightLimitDeadlift.Name = "TotalWeightLimit"
totalWeightLimitDeadlift.Value = 0.0
local WeightsStatsTurf = Instance.new("Folder", player)
WeightsStatsTurf.Name = "TurfWeights"
local TurfNumber25Kg = Instance.new("IntValue", WeightsStatsTurf)
TurfNumber25Kg.Name = "Number25Kg"
TurfNumber25Kg.Value = 0
local TurfTotalWeight = Instance.new("NumberValue", WeightsStatsTurf)
TurfTotalWeight.Name = "TotalWeight"
TurfTotalWeight.Value = 0.0
local TurfTotalWeightLimit = Instance.new("NumberValue", WeightsStatsTurf)
TurfTotalWeightLimit.Name = "TotalWeightLimit"
TurfTotalWeightLimit.Value = 0.0
local TurfWeightSet = Instance.new("NumberValue", WeightsStatsTurf)
TurfWeightSet.Name = "WeightSet"
TurfWeightSet.Value = 0.0
local WeightsStatsBarCurl = Instance.new("Folder", player)
WeightsStatsBarCurl.Name = "WeightsInfoBarcurl"
local barCurlNumber25Kg = Instance.new("IntValue", WeightsStatsBarCurl)
barCurlNumber25Kg.Name = "Number25Kg"
barCurlNumber25Kg.Value = 0
local barCurlTotalWeight = Instance.new("NumberValue", WeightsStatsBarCurl)
barCurlTotalWeight.Name = "TotalWeight"
barCurlTotalWeight.Value = 0.0
local barCurlTotalWeightLimit = Instance.new("NumberValue", WeightsStatsBarCurl)
barCurlTotalWeightLimit.Name = "TotalWeightLimit"
barCurlTotalWeightLimit.Value = 0.0
local WeightsStatsDumbells = Instance.new("Folder", player)
WeightsStatsDumbells.Name = "WeightsInfoDumbell"
local dumbellsNumber5Kg = Instance.new("IntValue", WeightsStatsDumbells)
dumbellsNumber5Kg.Name = "Number5Kg"
dumbellsNumber5Kg.Value = 0
local dumbellsTotalWeight = Instance.new("NumberValue", WeightsStatsDumbells)
dumbellsTotalWeight.Name = "TotalWeight"
dumbellsTotalWeight.Value = 0.0
local dumbellsTotalWeightLimit = Instance.new("NumberValue", WeightsStatsDumbells)
dumbellsTotalWeightLimit.Name = "TotalWeightLimit"
dumbellsTotalWeightLimit.Value = 0.0
local weightsPack = Instance.new("Folder", player)
weightsPack.Name = "WeightsPack"
local OwnBronze = Instance.new("BoolValue", weightsPack)
OwnBronze.Name = "OwnBronze"
OwnBronze.Value = false
local OwnSilver = Instance.new("BoolValue", weightsPack)
OwnSilver.Name = "OwnSilver"
OwnSilver.Value = false
local OwnGold = Instance.new("BoolValue", weightsPack)
OwnGold.Name = "OwnGold"
OwnGold.Value = false
local OwnDiamond = Instance.new("BoolValue", weightsPack)
OwnDiamond.Name = "OwnDiamond"
OwnDiamond.Value = false
local OwnEmerald = Instance.new("BoolValue", weightsPack)
OwnEmerald.Name = "OwnEmerald"
OwnEmerald.Value = false
local wheyPack = Instance.new("Folder", player)
wheyPack.Name = "WheyPack"
local forbiddenWheyAmount = Instance.new("NumberValue", wheyPack)
forbiddenWheyAmount.Name = "ForbiddenWheyAmount"
forbiddenWheyAmount.Value = 0
local divineWheyAmount = Instance.new("NumberValue", wheyPack)
divineWheyAmount.Name = "DivineWheyAmount"
divineWheyAmount.Value = 0
local legendaryWheyAmount = Instance.new("NumberValue", wheyPack)
legendaryWheyAmount.Name = "LegendaryWheyAmount"
legendaryWheyAmount.Value = 0
local epicWheyAmount = Instance.new("NumberValue", wheyPack)
epicWheyAmount.Name = "EpicWheyAmount"
epicWheyAmount.Value = 0
local rareWheyAmount = Instance.new("NumberValue", wheyPack)
rareWheyAmount.Name = "RareWheyAmount"
rareWheyAmount.Value = 0
local uncommonWheyAmount = Instance.new("NumberValue", wheyPack)
uncommonWheyAmount.Name = "UncommonWheyAmount"
uncommonWheyAmount.Value = 0
local standardWheyAmount = Instance.new("NumberValue", wheyPack)
standardWheyAmount.Name = "StandardWheyAmount"
standardWheyAmount.Value = 0
local weightsTurfPlayerFolder = Instance.new("Folder", player)
weightsTurfPlayerFolder.Name = "WeightsTurf"
local weightsTurfInPlayer = Instance.new("Folder", weightsTurfPlayerFolder)
weightsTurfInPlayer.Name = "Weights"
local DefaultAnimations = Instance.new("Folder", player)
DefaultAnimations.Name = "DefaultAnimations"
local BlockActivated = Instance.new("BoolValue", player)
BlockActivated.Name = "Block"
BlockActivated.Value = false
local playerID = ps:GetUserIdFromNameAsync(player.Name);
local success, result = pcall(function()
return playerClassDB:GetAsync(playerID);
end)
if not success then
warn("Data was not loaded.");
end
task.wait(1.5)
onJoinTable[result == nil or result == "null"](player, result)
end
function save(playerId, playerClass)
local success, err = pcall(function()
local jsonStructure = http:JSONEncode(playerClass);
playerClassDB:SetAsync(playerId, jsonStructure);
end)
end
function playerLeaves(player)
local muscleMass = player:WaitForChild("CharStats").MuscleMass.Value
local health = player:WaitForChild("CharStats").Health.Value
local strength = player:WaitForChild("CharStats").Strength.Value
local resistance = player:WaitForChild("CharStats").Resistance.Value
local speed = player:WaitForChild("CharStats").Speed.Value
local height = player:WaitForChild("Height").Value
local Wins = player:WaitForChild("leaderstats").Wins.Value
local Kill = player:WaitForChild("leaderstats").Kill.Value
local Rebirth = player:WaitForChild("leaderstats").Rebirth.Value
local RebirthTotalMultiplier = player:WaitForChild("RebirthTotalMultiplier").Value
local LapsDoneTurf = player:WaitForChild("LapsDoneTurf").Value
local NumberConnexion = player:WaitForChild("NumberConnexion").Value + 1
local bodyBuildingLevel = player:WaitForChild("DisciplineCharStats").Bodybuilding.Value
local bodyBuildingExp = player:WaitForChild("BodybuildingExp").Value
local bodyBuildingExpMax = player:WaitForChild("BodybuildingExpMax").Value
local bodyBuildingExpMin = player:WaitForChild("BodybuildingExpMin").Value
local calisthenicsLevel = player:WaitForChild("DisciplineCharStats").Calisthenic.Value
local calisthenicsExp = player:WaitForChild("HealthDiscipline").HealthExp.Value
local calisthenicsExpMax = player:WaitForChild("HealthDiscipline").HealthExpMax.Value
local calisthenicsExpMin = player:WaitForChild("HealthDiscipline").HealthExpMin.Value
local powerLiftingLevel = player:WaitForChild("DisciplineCharStats").PowerLifting.Value
local powerLiftingExp = player:WaitForChild("StrengthDiscipline").StrengthExp.Value
local powerLiftingExpMax = player:WaitForChild("StrengthDiscipline").StrengthExpMax.Value
local powerLiftingExpMin = player:WaitForChild("StrengthDiscipline").StrengthExpMin.Value
local fightingLevel = player:WaitForChild("DisciplineCharStats").Fighting.Value
local fightingExp = player:WaitForChild("ResistanceDiscipline").ResistanceExp.Value
local fightingExpMax = player:WaitForChild("ResistanceDiscipline").ResistanceExpMax.Value
local fightingExpMin = player:WaitForChild("ResistanceDiscipline").ResistanceExpMin.Value
local runningLevel = player:WaitForChild("DisciplineCharStats").Running.Value
local runningExp = player:WaitForChild("SpeedDiscipline").SpeedExp.Value
local runningExpMax = player:WaitForChild("SpeedDiscipline").SpeedExpMax.Value
local runningExpMin = player:WaitForChild("SpeedDiscipline").SpeedExpMin.Value
local OwnBronze = player:WaitForChild("WeightsPack").OwnBronze.Value
local OwnSilver = player:WaitForChild("WeightsPack").OwnSilver.Value
local OwnGold = player:WaitForChild("WeightsPack").OwnGold.Value
local OwnDiamond = player:WaitForChild("WeightsPack").OwnDiamond.Value
local OwnEmerald = player:WaitForChild("WeightsPack").OwnEmerald.Value
local ForbiddenWheyAmount = player:WaitForChild("WheyPack").ForbiddenWheyAmount.Value
local DivineWheyAmount = player:WaitForChild("WheyPack").DivineWheyAmount.Value
local LegendaryWheyAmount = player:WaitForChild("WheyPack").LegendaryWheyAmount.Value
local EpicWheyAmount = player:WaitForChild("WheyPack").EpicWheyAmount.Value
local RareWheyAmount = player:WaitForChild("WheyPack").RareWheyAmount.Value
local UncommonWheyAmount = player:WaitForChild("WheyPack").UncommonWheyAmount.Value
local StandardWheyAmount = player:WaitForChild("WheyPack").StandardWheyAmount.Value
print("SPEED EXP VALUE : " .. player:WaitForChild("SpeedDiscipline").SpeedExp.Value)
local Power = player:WaitForChild("leaderstats").Power.Value
for i, v in player.DefaultAnimations:GetChildren() do
table.insert(AnimationsIdTable, v.Value)
table.insert(AnimationsNameTable, v.Name)
end
local DeadliftTotalWeight = player:WaitForChild("WeightsInfoDeadlift").TotalWeight.Value
local DeadliftTotalWeightLimit = player:WaitForChild("WeightsInfoDeadlift").TotalWeightLimit.Value
local Deadlift_25Kg = player:WaitForChild("WeightsInfoDeadlift").Number25Kg.Value
local BarCurlTotalWeight = player:WaitForChild("WeightsInfoBarcurl").TotalWeight.Value
local BarCurlTotalWeightLimit = player:WaitForChild("WeightsInfoBarcurl").TotalWeightLimit.Value
local BarCurl_25Kg = player:WaitForChild("WeightsInfoBarcurl").Number25Kg.Value
local TotalWeight = player:WaitForChild("WeightsInfoBench").TotalWeight.Value
local TotalWeightLimit = player:WaitForChild("WeightsInfoBench").TotalWeightLimit.Value
local _25Kg = player:WaitForChild("WeightsInfoBench").Number25Kg.Value
local TurfTotalWeight = player:WaitForChild("TurfWeights").TotalWeight.Value
local TurfTotalWeightLimit = player:WaitForChild("TurfWeights").TotalWeightLimit.Value
local TurfWeightSet = player:WaitForChild("TurfWeights").WeightSet.Value
local Turf_25Kg = player:WaitForChild("TurfWeights").Number25Kg.Value
local DumbellsTotalWeight = player:WaitForChild("WeightsInfoDumbell").TotalWeight.Value
local DumbellsTotalWeightLimit = player:WaitForChild("WeightsInfoDumbell").TotalWeightLimit.Value
local Dumbells_5Kg = player:WaitForChild("WeightsInfoDumbell").Number5Kg.Value
local ClickCounter = player:WaitForChild("ClickCounter").Value
local Gender = player:WaitForChild("Gender").Value
for i, v in player.WeightsTurf.Weights:GetChildren() do
table.insert(weightsTurfTable, v.Name)
end
for i, punchingBag in workspace.Workouts.PunchingBags:GetChildren() do
if punchingBag.Bag.Owner.Value == player then
punchingBag.Bag.BrickColor = BrickColor.new("Really black")
punchingBag.Bag.Material = Enum.Material.SmoothPlastic
punchingBag.Bag.Owner.Value = nil
punchingBag.Bag.ClickDetector.MaxActivationDistance = 15
end
end
for i, deadlift in workspace.Workouts.Deadlift:GetChildren() do
if deadlift.DeadliftOwner.Value == player then
deadlift.DeadliftOwner.Value = nil
deadlift.Bar.ClickDetector.MaxActivationDistance = 15
for i, v in deadlift:GetChildren() do
if v:IsA("Part") and v.Name ~= "BarWeldLeft" and v.Name ~= "BarWeldRight" and v.Name ~= "DeadliftAlignmentPoint" then
v.Transparency = 0.0
end
end
for i, v in deadlift:GetChildren() do
if v:IsA("Part") and v.Name ~= "LeftGrip" and v.Name ~= "RightGrip" and v.Name ~= "DeadliftAlignementPoint" then
v.BrickColor = BrickColor.new("Medium stone grey")
end
end
end
end
playerClasses[player.UserId].musclemass = muscleMass
playerClasses[player.UserId].health = health
playerClasses[player.UserId].strength = strength
playerClasses[player.UserId].resistance = resistance
playerClasses[player.UserId].speed = speed
playerClasses[player.UserId].height = height
playerClasses[player.UserId].lapsdoneturf = LapsDoneTurf
playerClasses[player.UserId].numberconnexion = NumberConnexion
playerClasses[player.UserId].power = Power
playerClasses[player.UserId].wins = Wins
playerClasses[player.UserId].kill = Kill
playerClasses[player.UserId].rebirth = Rebirth
playerClasses[player.UserId].rebirthtotalmultiplier = RebirthTotalMultiplier
playerClasses[player.UserId].bodybuilding = bodyBuildingLevel
playerClasses[player.UserId].bodybuildingexp = bodyBuildingExp
playerClasses[player.UserId].bodybuildingexpmax = bodyBuildingExpMax
playerClasses[player.UserId].bodybuildingexpmin = bodyBuildingExpMin
playerClasses[player.UserId].calisthenics = calisthenicsLevel
playerClasses[player.UserId].calisthenicsexp = calisthenicsExp
playerClasses[player.UserId].calisthenicsexpmax = calisthenicsExpMax
playerClasses[player.UserId].calisthenicsexpmin = calisthenicsExpMin
playerClasses[player.UserId].powerlifting = powerLiftingLevel
playerClasses[player.UserId].powerliftingsexp = powerLiftingExp
playerClasses[player.UserId].powerliftingexpmax = powerLiftingExpMax
playerClasses[player.UserId].powerliftingexpmin = powerLiftingExpMin
playerClasses[player.UserId].fighting = fightingLevel
playerClasses[player.UserId].fightingsexp = fightingExp
playerClasses[player.UserId].fightingexpmax = fightingExpMax
playerClasses[player.UserId].fightingexpmin = fightingExpMin
playerClasses[player.UserId].animationscharactersid = AnimationsIdTable
playerClasses[player.UserId].animationscharactersname = AnimationsNameTable
playerClasses[player.UserId].running = runningLevel
playerClasses[player.UserId].runningsexp = runningExp
playerClasses[player.UserId].runningexpmax = runningExpMax
playerClasses[player.UserId].runningexpmin = runningExpMin
playerClasses[player.UserId].deadlifttotalweight = DeadliftTotalWeight
playerClasses[player.UserId].deadlifttotalweightlimit = DeadliftTotalWeightLimit
playerClasses[player.UserId].deadliftnumber25kg = Deadlift_25Kg
playerClasses[player.UserId].barcurltotalweight = BarCurlTotalWeight
playerClasses[player.UserId].barcurltotalweightlimit = BarCurlTotalWeightLimit
playerClasses[player.UserId].barcurlnumber25kg = BarCurl_25Kg
playerClasses[player.UserId].totalweight = TotalWeight
playerClasses[player.UserId].totalweightlimit = TotalWeightLimit
playerClasses[player.UserId].number25kg = _25Kg
playerClasses[player.UserId].turfweights = weightsTurfTable
playerClasses[player.UserId].turftotalweight = TurfTotalWeight
playerClasses[player.UserId].turftotalweightlimit = TurfTotalWeightLimit
playerClasses[player.UserId].turfweightset = TurfWeightSet
playerClasses[player.UserId].turfnumber25kg = Turf_25Kg
playerClasses[player.UserId].dumbellstotalweight = DumbellsTotalWeight
playerClasses[player.UserId].dumbellstotalweightlimit = DumbellsTotalWeightLimit
playerClasses[player.UserId].dumbellsnumber5kg = Dumbells_5Kg
playerClasses[player.UserId].ownbronze = OwnBronze
playerClasses[player.UserId].ownsilver = OwnSilver
playerClasses[player.UserId].owngold = OwnGold
playerClasses[player.UserId].owndiamond = OwnDiamond
playerClasses[player.UserId].ownemerald = OwnEmerald
playerClasses[player.UserId].forbiddenwheyamount = ForbiddenWheyAmount
playerClasses[player.UserId].divinewheyamount = DivineWheyAmount
playerClasses[player.UserId].legendarywheyamount = LegendaryWheyAmount
playerClasses[player.UserId].epicwheyamount = EpicWheyAmount
playerClasses[player.UserId].rarewheyamount = RareWheyAmount
playerClasses[player.UserId].uncommonwheyamount = UncommonWheyAmount
playerClasses[player.UserId].standardwheyamount = StandardWheyAmount
playerClasses[player.UserId].clickcounter = ClickCounter
playerClasses[player.UserId].gender = Gender
save(player.UserId, playerClasses[player.UserId]);
print(playerClasses[player.UserId].totalweight)
print(playerClasses[player.UserId].totalweightlimit)
print(playerClasses[player.UserId].weightset)
print(playerClasses[player.UserId].number25kg)
end
-- EVENTS --
ps.PlayerAdded:Connect(playerJoined);
ps.PlayerRemoving:Connect(playerLeaves);
playerClass Module script :
local playerClass = {};
playerClass.__index = playerClass;
-- Constructor --
function playerClass.new(player, self)
repeat task.wait() until player.Character ~= nil;
if self then return setmetatable(self, playerClass) end;
local self = setmetatable({}, playerClass);
self.name = player.Name;
self.character = player.Character;
self.kill = player.leaderstats.Kill.Value;
self.wins = player.leaderstats.Wins.Value;
self.power = player.leaderstats.Power.Value;
self.rebirth = player.leaderstats.Rebirth.Value;
self.numberconnexion = player:WaitForChild("NumberConnexion").Value;
self.rebirthtotalmultiplier = player.RebirthTotalMultiplier.Value;
self.bodybuildingexp = player.BodybuildingExp.Value;
self.bodybuildingexpmax = player.BodybuildingExpMax.Value;
self.bodybuildingexpmin = player.BodybuildingExpMin.Value;
self.calisthenicsexp = player:WaitForChild("HealthDiscipline").HealthExp.Value;
self.calisthenicsexpmax = player:WaitForChild("HealthDiscipline").HealthExpMax.Value;
self.calisthenicsexpmin = player:WaitForChild("HealthDiscipline").HealthExpMin.Value;
self.powerliftingsexp = player:WaitForChild("StrengthDiscipline").StrengthExp.Value;
self.powerliftingexpmax = player:WaitForChild("StrengthDiscipline").StrengthExpMax.Value;
self.powerliftingexpmin = player:WaitForChild("StrengthDiscipline").StrengthExpMin.Value;
self.fightingsexp = player:WaitForChild("ResistanceDiscipline").ResistanceExp.Value;
self.fightingexpmax = player:WaitForChild("ResistanceDiscipline").ResistanceExpMax.Value;
self.fightingexpmin = player:WaitForChild("ResistanceDiscipline").ResistanceExpMin.Value;
self.runningsexp = player:WaitForChild("SpeedDiscipline").SpeedExp.Value;
self.runningexpmax = player:WaitForChild("SpeedDiscipline").SpeedExpMax.Value;
self.runningexpmin = player:WaitForChild("SpeedDiscipline").SpeedExpMin.Value;
self.number25kg = player:WaitForChild("WeightsInfoBench").Number25Kg.Value;
self.totalweight = player:WaitForChild("WeightsInfoBench").TotalWeight.Value;
self.totalweightlimit = player:WaitForChild("WeightsInfoBench").TotalWeightLimit.Value;
self.deadliftnumber25kg = player:WaitForChild("WeightsInfoDeadlift").Number25Kg.Value;
self.deadlifttotalweight = player:WaitForChild("WeightsInfoDeadlift").TotalWeight.Value;
self.deadlifttotalweightlimit = player:WaitForChild("WeightsInfoDeadlift").TotalWeightLimit.Value;
self.turfweights = player.WeightsTurf;
self.turfnumber25kg = player:WaitForChild("TurfWeights").Number25Kg.Value;
self.turftotalweight = player:WaitForChild("TurfWeights").TotalWeight.Value;
self.turftotalweightlimit = player:WaitForChild("TurfWeights").TotalWeightLimit.Value;
self.turfweightset = player:WaitForChild("TurfWeights").WeightSet.Value;
self.barcurlnumber25kg = player:WaitForChild("WeightsInfoBarcurl").Number25Kg.Value;
self.barcurltotalweight = player:WaitForChild("WeightsInfoBarcurl").TotalWeight.Value;
self.barcurltotalweightlimit = player:WaitForChild("WeightsInfoBarcurl").TotalWeightLimit.Value;
self.dumbellsweights = player.WeightsDumbells;
self.dumbellsnumber5kg = player:WaitForChild("WeightsInfoDumbell").Number5Kg.Value;
self.dumbellstotalweight = player:WaitForChild("WeightsInfoDumbell").TotalWeight.Value;
self.dumbellstotalweightlimit = player:WaitForChild("WeightsInfoDumbell").TotalWeightLimit.Value;
self.animationscharactersid = player:WaitForChild("DefaultAnimations");
self.animationscharactersname = player:WaitForChild("DefaultAnimations");
self.lapsdoneturf = player:WaitForChild("LapsDoneTurf").Value
self.strength = player:WaitForChild("CharStats").Strength.Value;
self.speed = player:WaitForChild("CharStats").Speed.Value;
self.musclemass = player:WaitForChild("CharStats").MuscleMass.Value;
self.resistance = player:WaitForChild("CharStats").Resistance.Value;
self.health = player:WaitForChild("CharStats").Health.Value;
self.calisthenics = player:WaitForChild("DisciplineCharStats").Calisthenic.Value;
self.bodybuilding = player:WaitForChild("DisciplineCharStats").Bodybuilding.Value;
self.running = player:WaitForChild("DisciplineCharStats").Running.Value;
self.powerlifting = player:WaitForChild("DisciplineCharStats").PowerLifting.Value;
self.fighting = player:WaitForChild("DisciplineCharStats").Fighting.Value;
self.height = player.Height.Value;
self.ownbronze = player:WaitForChild("WeightsPack").OwnBronze.Value;
self.ownsilver = player:WaitForChild("WeightsPack").OwnSilver.Value;
self.owngold = player:WaitForChild("WeightsPack").OwnGold.Value;
self.owndiamond = player:WaitForChild("WeightsPack").OwnDiamond.Value;
self.ownemerald = player:WaitForChild("WeightsPack").OwnEmerald.Value;
self.forbiddenwheyamount = player:WaitForChild("WheyPack").ForbiddenWheyAmount.Value;
self.divinewheyamount = player:WaitForChild("WheyPack").DivineWheyAmount.Value;
self.legendarywheyamount = player:WaitForChild("WheyPack").LegendaryWheyAmount.Value;
self.epicwheyamount = player:WaitForChild("WheyPack").EpicWheyAmount.Value;
self.rarewheyamount = player:WaitForChild("WheyPack").RareWheyAmount.Value;
self.uncommonwheyamount = player:WaitForChild("WheyPack").UncommonWheyAmount.Value;
self.standardwheyamount = player:WaitForChild("WheyPack").StandardWheyAmount.Value;
self.clickcounter = player:WaitForChild("ClickCounter").Value;
self.gender = player:WaitForChild("Gender").Value;
return self;
end
function playerClass:setCharacter(character)
self.character = character;
end
function playerClass:setName(name)
self.name = name;
end
function playerClass:teleportPlayer(newCframe)
self.Character.HumanoidRootPart.CFrame = newCframe;
end
function playerClass:addMuscleMass(value)
self.musclemass += value;
end
return playerClass;