welp it does not work
How so? what does it do? Dang character minimumβ¦
ima be afk for 10 minutes
hy im back ima send a video on what it does
If thats the case make it so a level/whatever can only have a certain amount of money then they have to buy an upgrade to get more money. Hopefully my idea was good if not eh.
well i would hav to talk to my partner about it
1 Like
but by any chance do u know how to do that
Nope Iβm not a scripter lol I build stuff.
oh ok
Try this code?
local DataStoreService = game:GetService("DataStoreService")
local MyDataStore = DataStoreService:GetDataStore('MyDataStore')
local cap = 2
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = 'leaderstats'
local currency = Instance.new("IntValue", leaderstats)
currency.Name = 'Rank'
currency.Value = 0
local PlayerRankId = 'Rank_'..player.UserId
local RankData
local s, err = pcall(function()
RankData = MyDataStore:GetAsync(PlayerRankId)
end)
if s then
currency.Value = RankData
else
warn(err)
end
-- check for rank updates
currency.Changed:Connect(function(newVal)
if newVal > cap then
currency.Value = cap
end
end)
end)
game.Players.PlayerRemoving:Connect(function(player)
local PlayerRankId = 'Rank_'..player.UserId
local s, err = pcall(function()
MyDataStore:SetAsync(PlayerRankId, player.leaderstats.Rank.Value)
end)
if s then
print('Stored all Player Data')
else
warn(err)
end
end)
It includes a .Changed
event for your Rank leaderstats. It should allow you to rank up to the cap, but not above it.
1 Like
i will try this
1 Like
omg thx dude it actually works
1 Like
Awesome! Glad to help.
If you need more help, feel free to post back here or reach out!
ok thks
1 Like