Hey, devfourm. I’m currently making a game and I am trying to make an RP Name datastore. I’m brand new with datastores so I’m 100% sure I messed something up with the script because it’s not working like it’s supposed to. What I’m trying to make it do is that whenever the player’s RP Name value is changed it will set it in the datastore but for some reason, it’s not working. I hope you can help me with my script, thanks
The script
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
local NameStore = DataStoreService:GetDataStore("NameStore")
game.Players.PlayerAdded:Connect(function(plr)
local RPName = NameStore:GetAsync(plr.UserId)
if RPName == nil then
RPName = "No Name"
NameStore:SetAsync(plr.UserId, RPName)
end
local Data = plr:WaitForChild("Data")
local NameValue = Instance.new("StringValue", Data)
NameValue.Name = "RPName"
NameValue.Value = RPName
NameValue.Changed:Connect(function(nv)
NameStore:SetAsync(plr.UserId, nv)
end)
end)
Showing it not working.
Setting the name - https://gyazo.com/42d3f8038ea441666743803cdaaa418f
Looking at it again - https://gyazo.com/1854403ee1142ce7c0e7fedd04d152c8