Gold and EXP will only stay at 10 and not go anything past 10?
Asked by
7 years ago Edited 7 years ago
when you kill a mob in the rpg, it gives 5 gold and 5 xp but no matter how many times you kill something or how much xp and gold you get, it will not go past 10. please help here is the script
01 | local datastore = game:GetService( "DataStoreService" ):GetDataStore( "MyRPGDataStore" ) |
04 | game.Players.PlayerAdded:connect( function (player) |
05 | local leaderstats = Instance.new( "IntValue" ) |
06 | leaderstats.Name = "leaderstats" |
07 | leaderstats.Parent = player |
09 | local xd = Instance.new( "IntConstrainedValue" ) |
11 | xd.Parent = leaderstats |
13 | xd.MaxValue = workspace:FindFirstChild( "GameSettings" ).MaxLevel.Value |
16 | local qe = Instance.new( "IntConstrainedValue" ) |
18 | qe.Parent = leaderstats |
20 | xd.MaxValue = workspace:FindFirstChild( "GameSettings" ).MaxEXP.Value |
23 | local ss = Instance.new( "IntConstrainedValue" ) |
25 | ss.Parent = leaderstats |
27 | xd.MaxValue = workspace:FindFirstChild( "GameSettings" ).MaxGold.Value |
30 | local key = "user-" .. player.userId |
32 | local storeditems = datastore:GetAsync(key) |
34 | xd.Value = storeditems [ 1 ] |
35 | qe.Value = storeditems [ 2 ] |
36 | ss.Value = storeditems [ 3 ] |
38 | local items = { xd.Value, qe.Value, ss.Value } |
39 | datastore:SetAsync(key, items) |
43 | local stats = player:FindFirstChild( "leaderstats" ) |
44 | local aitems = { stats.Level.Value, stats.EXP.Value, stats.Gold.Value } |
45 | local key = "user-" .. player.userId |
46 | datastore:SetAsync(key, aitems) |
50 | game.Players.PlayerRemoving:connect( function (player) |
51 | local stats = player:FindFirstChild( "leaderstats" ) |
52 | local items = { stats.Level.Value, stats.EXP.Value, stats.Gold.Value } |
53 | local key = "user-" .. player.userId |
54 | datastore:SetAsync(key, items) |