I need the game to save a 4 number sequence with a dot in between the numbers(so only uses one data store) I've looked through Data Persistance and Data Stores but I can't figure it out...
I've written many lines of code that use Data persistence but I can't get anything to work in that at all
(my code is supposed to write the IP to a leaderboard)
the code that I wrote:
local DataStore = game:GetService("DataStoreService"):GetDataStore("IP")
local IP = "0.11.4.99"
game.Players.PlayerAdded:connect(function(player)
local leaderstats = Instance.new("Model")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local money = Instance.new("IntValue") --We create a new IntValue
money.Name = "IP" --this is the name you want the leader-stat to be when it shows up in-game.
money.Value = IP --this is the value of money the new player starts out with. To change this, you can add some more code (shown later)
money.Parent = leaderstats -- Set the money object as a child of the leaderstats object.
end)
game.Players.PlayerRemoving:connect(function(p)---set played to true-------------------------------------------------------------------
p:WaitForDataReady()
local played = p:LoadBoolean("Played")
if played == false then
played = true
end
end)
game.Players.PlayerAdded:connect(function(p)------------------------------------creating new IP----------------------------------------------
p:WaitForDataReady()
local played = p:LoadBoolean("Played")
if played == false then
local rndm1 = math.random(254)
local rndm2 = math.random(254)
local rndm3 = math.random(254)
local rndm4 = math.random(254)
IP = rndm1.. ".".. rndm2.. ".".. rndm3.. ".".. rndm4
print(IP)
end
end)
print(IP)
game.Players.PlayerAdded:connect(function(player)----------------------------------------------------------------------------------------
player:WaitForDataReady()
local played = player:LoadBoolean("Played")
if played == false then
player:SaveString("IP", IP)
end
end)
game.Players.PlayerAdded:connect(function(p)------------------Load IP---------------------------------------------------------------------
p:WaitForDataReady()
local IP = p:LoadString("IP")
end)
the leaderboard is always 0 not matter what(also sorry the code is a bit messy)
If anyone has a better way I should do this or a fix for it, it would be appreciated!

2 comments
https://www.youtube.com/watch?v=tOOS9lMIYes maybe this will help?
thanks that helped!