So, I'm having trouble getting a leaderstats string value to change automatically after an IntValue changes in correspondence to this. How would I go about doing this?
I have:
datastore = game:GetService("DataStoreService"):GetDataStore("rating")
game.Players.PlayerAdded:connect(function(player)
local leaderstats = Instance.new("Model", player)
leaderstats.Name = "leaderstats"
local rating = Instance.new("IntValue", leaderstats)
rating.Name = "Rating"
local ranking = Instance.new("StringValue", leaderstats)
ranking.Name = "Rank"
local key = "user_"..player.userId
if (datastore:GetAsync(key) ~= 0) then
rating.Value = datastore:GetAsync(key)
else
rating.Value = 1500
end
rating.Changed:connect(function(val)
datastore:SetAsync(key, val)
end)
if (rating.Value <= 1500) then
ranking.Value = "Rust I"
elseif (rating.Value > 1500 and rating.Value <= 2000) then
ranking.Value = "Rust II"
elseif (rating.Value > 2000 and rating.Value <= 2500) then
ranking.Value = "Rust III"
end
end)

1 comment
Ooh, yeah, and the datastore itself is working fine.