Saving a string value to leaderstats through data store

I use bind to close and I can save Int Values but my problem is strings


script.Parent.MouseButton1Click:Connect(function()

plr.leaderstats.Alias.Value = script.Parent.Parent.TextBox.Text

end)   
this is the change alias script

You need to use a remote event to so that the server can change it, since the datastore doesn’t save local values

server script


rem.OnServerEvent:Connect(function(plr)

plr.leaderstats.Alias.Value = plr.PlayerGui.ScreenGui.TextBox.Text

print(plr.PlayerGui.ScreenGui.TextBox.Text)

plr.leaderstats.Alias.Value = plr.PlayerGui.ScreenGui.TextBox.Text

end)```

local script inside player gui -


```local plr = game.Players.LocalPlayer
local remote = game.ReplicatedStorage.GiveAlias

script.Parent.MouseButton1Click:Connect(function()
remote:FireServer(plr)
end)```


doesnt work, it prints blank for some reason

Try saving the string in a table

How would I go about saving a string to a table

You cant get the text from a textbox, because the player entered it locally. You have to pass the text as an argument. Also, you don’t add plr in as an argument for :FireServer()

I’m not really understanding what your implying, can you elaborate more?

remote:FireServer(plr.PlayerGui.ScreenGui.TextBox.Text)

And then in the server script

rem.OnServerEvent:Connect(function(plr, TextBoxText)
    plr.leaderstats.Alias.Value = TextBoxText
end)

Oh I tried that before but I never showed it on here, but it didn’t work

Here’s a little snippet code for saving tables

ds:SetAsync({'string'},userid) -- saves the data.

local dataRetrieved = ds:GetAsync({'string'},userid)
2 Likes