i have a multipliers shop that basically multiplies the amount of x the player earns when they collect an item ( coins, etc) but when it saves the data it saves to the player properly, however the loading portion is the messed up part. It loads into rep storage and for the first player thats great however when theres more than 1 player it messes up and replicates the first player's multipliers to everyone else. Should i save a value to a table and then set it to the bool value? where would that bool value end up? in rep storage, server storage, or the player themselves? i have alot of unknowns when making this script, i wanted to tackle a harder script for myself but i think i bit off more than i can chew
local replicatedstorage = game:GetService("ReplicatedStorage")
local remotecoins = replicatedstorage.Multipliers.CoinsMultiplier
local remotecoils = replicatedstorage.Multipliers.CoilsMultiplier
local remotepetluck = replicatedstorage.Multipliers.PetLuckMultiplier
local datastore = game:GetService("DataStoreService")
local multipliers = datastore:GetDataStore("Multipliers")
game.Players.PlayerAdded:Connect(function(player)
local data1
local data2
local data3
local data4
local data5
local data6
local success, errorMessage = pcall(function()
data1 = multipliers:GetAsync(player.UserId .. "-Springsx")
data2 = multipliers:GetAsync(player.UserId .. "-Coinsx")
data3 = multipliers:GetAsync(player.UserId .. "-PetLuckx")
data4 = multipliers:GetAsync(player.UserId .. "-SpringsCost")
data5 = multipliers:GetAsync(player.UserId .. "-CoinsCost")
data6 = multipliers:GetAsync(player.UserId .. "-PetLuckCost")
print(data1)
print(data2)
print(data3)
print(data4)
print(data5)
print(data6)
end)
if success then
print("Success, loaded multipliers")
print(data1)
print(data2)
print(data3)
print(data4)
print(data5)
print(data6)
if data1 and data4 then
remotecoils.Multiplier.Value = data1
remotecoils.MultiplierCost.Value = data4
else
remotecoils.Multiplier.Value = "1"
remotecoils.MultiplierCost.Value = "100"
end
if data2 and data5 then
remotecoins.Multiplier.Value = data2
remotecoins.MultiplierCost.Value = data5
else
remotecoins.Multiplier.Value = "1"
remotecoins.MultiplierCost.Value = "100"
end
if data3 and data6 then
remotepetluck.Multiplier.Value = data3
remotepetluck.MultiplierCost.Value = data6
else
remotepetluck.Multiplier.Value = "1"
remotepetluck.MultiplierCost.Value = "1000"
end
else
print(errorMessage)
remotecoils.Multiplier.Value = "1"
remotecoils.MultiplierCost.Value = "100"
remotecoins.Multiplier.Value = "1"
remotecoins.MultiplierCost.Value = "100"
remotepetluck.Multiplier.Value = "1"
remotepetluck.MultiplierCost.Value = "1000"
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local coilsx = remotecoils.Multiplier.Value
local coinsx = remotecoins.Multiplier.Value
local petluckx = remotepetluck.Multiplier.Value
local coilsc = remotecoils.MultiplierCost.Value
local coinsc = remotecoins.MultiplierCost.Value
local petluckc = remotepetluck.MultiplierCost.value
local success, errorMessage = pcall(function()
multipliers:SetAsync(player.UserId .. "-Springsx", coilsx)
multipliers:SetAsync(player.UserId .. "-Coinsx", coinsx)
multipliers:SetAsync(player.UserId .. "-PetLuckx", petluckx)
multipliers:SetAsync(player.UserId .. "-SpringsCost", coilsc)
multipliers:SetAsync(player.UserId .. "-CoinsCost", coinsc)
multipliers:SetAsync(player.UserId .. "-PetLuckCost", petluckc)
end)
if success then
print("Saved Data Successfully")
else
print(errorMessage)
end
end)
game:BindToClose(function()
wait(7)
end)
any help would be great, im just hoping that the problem isnt too great and its something small like what i mention in terms of it being just replacing what the value is saved to and where.

1 comment
You may have to store your values into a table value like
local data = []