local datastore = game:GetService("DataStoreService"):GetDataStore("rP")
local serverstorage = game:GetService("ServerStorage")
game.Players.PlayerAdded:connect(function(plyr)
local rp = Instance.new("IntValue")
rp.Parent = serverstorage
rp.Name = "rP-"..plyr.Name
local key = "plyr"..plyr.userId
local username = Instance.new("StringValue")
username.Parent = serverstorage
username.Name = plyr.Name
username.Value = plyr.Name
local userid = Instance.new("IntValue")
userid.Parent = serverstorage
userid.Name = plyr.Name.."-id"
userid.Value = plyr.userId
local savedvalue = datastore:GetAsync(key)
if savedvalue then
rp.Value = savedvalue[1]
username.Value = savedvalue[2]
userid.Value = savedvalue[3]
else
datastore:SetAsync(key, rp.Value, username.Value,userid.Value)
end
end)
This is my code. I can't figure out why it cannot index savedvalue.
Any input?

2 comments
This doesn't fix it. I'm still getting the same error.
Oh wait, I think that this might be because sometimes DataStore will make the number be something like 10.0000000001. Since IntValues can't use decimals, try using math.floor() to round it down