You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? So im trying to make a sign up thingy so you type your name in for the account name and password and when you click create account it saves data so when you login it can see if that is a real account.
What is the issue? I have no idea how to do it lmao ._.
What solutions have you tried so far? used discord webhooks so it sends the account name so i can manually make the account.
Well, discord webhooks blocked Roblox API a while ago. You could save this in datastore, but the topic is a little concerning. Why are you having them sign up? Is it clear it’s not to phish passwords?
i ment that when it checks if its a real account i ment a account that has been made in the game, I understand why you think it was concerning. Its trying to check if the account exists in the game.
Gotcha - Nitro type needs people to sign up so they can access the platform and save data, with Roblox you’d already be able to reference their Roblox UserID for saving and all that. Would that work instead? Might just be an easier solution than having your own gatekeeper to play is why I ask.
Ok! Nicknames would also be something you could save with datastores. You could pursue the password-based system, but it would be an unnecessary step when you would reference the datastore with the players’ UserID anyways, so you’d know if they had a save or not. It’d also be complicated when a player forgets their password, and questionable legality/security since you would be potentially handling someones’ confidential info in plaintext.
Your table to update the datastore might start out looking something like:
local save = {
nickname = ""
}
Then you would create a DataStore (say, one named “playerSaves”) and set a key (the players’ UserId) to have “save” as a value.
I dont really understand data stores, so is this probally a start of the dataStore? ``` local DataStoreService = game:GetService(“DataStoreService”)
local AccountsData = DataStoreService:GetDataStore(“Accounts”)
Yep, you are on the right track. Within the PlayerAdded event you’d fetch their data from AccountsData. Such as:
game.Players.PlayerAdded:Connect(function(player)
local success, data = pcall(function()--When dealing with datastores, always wrap in pcalls
return AccountsData:GetAsync(player.UserId)
end)
if success then
print("Save found:")
print(data)
else
print("No save!")
end
end)
local Success, ErrorMessage = pcall(function()
YourDataStore:SetAsync(Player.UserId, {User = 'User', Password = 'Password'})
end)
if Success then
-- Bla bla bla
else
print(ErrorMessage);
end
Aye - the datastore was successfully fetched from, but you’ve not put anything into it, so it will return nil. “success” catches the error that the datastore could not be reached, which could be a disaster, so we wrap it in a pcall.
To add something to the datastore you’d want to use either SetAsync or UpdateAsync. The latter is always recommended for preventing data loss, but SetAsync is easier explained, so we will start with that. This one returns “success” and an error message rather than data, so printing the error message will give a clue as to the problem it had setting a datastores’ key. For your app it will look something like this:
local save = {
nickname = "Hello World!"
}
local success, errorMessage = pcall(function()
AccountsData:SetAsync(player.UserId, save)
end)
if not success then
print(errorMessage)
end
this is my create account script would this work?: ``` local DataStoreService = game:GetService(“DataStoreService”)
local AccountsData = DataStoreService:GetDataStore(“Accounts”)
local NameEnterBtn = script.Parent.EnterName
local SubmitNameBtn = script.Parent.SubmitName
local TextName = script.Parent.TextName
local Text = “Enter your username here.”
local ReplicatedStorage = game.ReplicatedStorage
local RegUsersFolder = ReplicatedStorage.RegisteredUsers
script.Parent.Continue.Visible = false
if not string.len(NameEnterBtn.Text) ~= 8 then
if not RegUsersFolder:FindFirstChild(NameEnterBtn.Text) then
TextName.Text = "Your account named: " .. NameEnterBtn.Text .. " has now been registered."
local save = {
nickname = NameEnterBtn.Text
}
local success, errorMessage = pcall(function()
AccountsData:SetAsync(player.UserId, save)
end)
if not success then
print(errorMessage)
end
else
script.Parent.Continue.Visible = false
TextName.Text = "Were sorry, but that account called " .. NameEnterBtn.Text .. " has already been registered. Please try again with a different name."
wait(5)
TextName.Text = Text
end
else
NameEnterBtn.Text = "Text must be less than 8 Characters!"
end
local AccountsData = DataStoreService:GetDataStore("Accounts")
game.Players.PlayerAdded:Connect(function(player)
local success, data = pcall(function()
return AccountsData:GetAsync(player.UserId)
end)
if success then
print("Save found:")
print(data)
else
print("No save!")
end
game.ReplicatedStorage.ChangeData.OnServerEvent:Connect(function(data)
local success, errorMessage = pcall(function()
AccountsData:SetAsync(player.UserId, data)
end)
if not success then
print(errorMessage)
end
end)
end)
local script (create Account script):
local SubmitNameBtn = script.Parent.SubmitName
local TextName = script.Parent.TextName
local Text = "Enter your username here."
local ReplicatedStorage = game.ReplicatedStorage
local RegUsersFolder = ReplicatedStorage.RegisteredUsers
script.Parent.Continue.Visible = false
local player = game.Players.LocalPlayer
SubmitNameBtn.MouseButton1Click:Connect(function()
if not string.len(NameEnterBtn.Text) ~= 8 then
if not RegUsersFolder:FindFirstChild(NameEnterBtn.Text) then
TextName.Text = "Your account named: " .. NameEnterBtn.Text .. " has now been registered."
local save = {
nickname = NameEnterBtn.Text
}
game.ReplicatedStorage.ChangeData:FireServer(save)
else
script.Parent.Continue.Visible = false
TextName.Text = "Were sorry, but that account called " .. NameEnterBtn.Text .. " has already been registered. Please try again with a different name."
wait(5)
TextName.Text = Text
end
else
NameEnterBtn.Text = "Text must be less than 8 Characters!"
end
end)
error: 18:32:51.919 104: Cannot store Instance in data store. Data stores can only accept valid UTF-8 characters. - Server - leaderstats:22