{Information}
So I want to know how to start a script to convert Value1 to another named Value2 when Value1 has a value of 50 then it will automatically convert it to a value of 2 for Value2, Basically the Values are the String Values in the leaderstats folder. For example, Value1 will be called EXP or XP and Value2 will be called Levels/Ranks. So how would I automatically convert 50 EXP/XP to 1 Level/Rank? Basically a level-up system, and how would I make the EXP/XP needed to Level/Rank up multiply by 2?
{Scripts}
LeaderStats(Works(Script)
local DataStoreService = game:GetService("DataStoreService")
local myDataStore = DataStoreService:GetDataStore("myDataStore")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Levels = Instance.new("IntValue")
Levels.Name = "Levels"
Levels.Parent = leaderstats
Levels.Value = 1
local Kills = Instance.new("IntValue")
Kills.Name = "Kills"
Kills.Parent = leaderstats
Kills.Value = 0
local Gems = Instance.new("IntValue")
Gems.Name = "Gems"
Gems.Parent = leaderstats
Gems.Value = 50
local EXP = Instance.new("IntValue")
EXP.Name = "EXP"
EXP.Parent = leaderstats
EXP.Value = 0
local data
local success, errormessage = pcall(function()
data = myDataStore:GetAsync(player.UserId.."-Levels")
data = myDataStore:GetAsync(player.UserId.."-Kills")
data = myDataStore:GetAsync(player.UserId.."-Gems")
data = myDataStore:GetAsync(player.UserId.."-EXP")
end)
if success then
Levels.Value = data
Kills.Value = data
Gems.Value = data
EXP.Value = data
else
print("There was a error whilst getting your data")
warn(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errormessage = pcall(function()
myDataStore:SetAsync(player.UserId.."-Levels",player.leaderstats.Levels.Value)
myDataStore:SetAsync(player.UserId.."-Kills",player.leaderstats.Kills.Value)
myDataStore:SetAsync(player.UserId.."-Gems",player.leaderstats.Gems.Value)
myDataStore:SetAsync(player.UserId.."-EXP",player.leaderstats.EXP.Value)
end)
if success then
print("Player Data successfully saved!")
else
print("There was a error when saving data")
warn(errormessage)
end
end)
Converter(Does not work(Script)
local Level = game.Players.LocalPlayer.leaderstats.Levels.Value
local EXP = game.Players.LocalPlayer.leaderstats.EXP.Value
if game.Players.LocalPlayer.leaderstats.EXP == "50" then
game.Players.LocalPlayer.leaderstats.EXP -50
game.Players.LocalPlayer.leaderstats.Level +1
end
If anybody could help me start off my script I would really appreciate it!

1 comment
Im not good at this stuff, so im going to offer this thing instead! https://devforum.roblox.com/t/level-systems-part-1/296963