Hi i am godpotato.
This time, i have a problem of scripting.
Serverscript is this one
local Players = game:GetService("Players")
local DataStore = game:GetService("DataStoreService"):GetDataStore("meqeuioiineentory")
local RemoteEvent = game.ReplicatedStorage.RemoteEvents.Shops
local Slots = game.StarterGui.Shop.SkillShop.ScreenGui.Inventory.Items
Players.PlayerAdded:Connect(function(player)
local playerId = player.UserId
local HowManyData = DataStore:GetAsync(playerId.."Howmany")
local ItemData = DataStore:GetAsync(playerId.."ItemName")
if ItemData == nil and HowManyData == nil then
ItemData = {}
HowManyData = {}
for i = 1, 117 do
table.insert(ItemData,"")
table.insert(HowManyData, 0)
end
HowManyData[1] = 1
HowManyData[2] = 1
HowManyData[3] = 1
ItemData[1] = "Dash"
ItemData[2] = "GravityCola"
ItemData[3] = "Muscle"
end
local LoadItemRemoteEvent = RemoteEvent.LoadItem
LoadItemRemoteEvent:FireClient(player, HowManyData,ItemData)
end)
Players.PlayerRemoving:Connect(function(player)
local playerId = player.UserId
local HowManyData = {}
for i = 1, 117 do
local slot = Slots:FindFirstChild("Slot"..i)
local Howmany = slot:FindFirstChild("HowMany")
table.insert(HowManyData,Howmany.Value)
end
local ItemData = {}
for i = 1, 117 do
local slot = Slots:FindFirstChild("Slot"..i)
local Howmany = slot:FindFirstChild("Itemname")
table.insert(ItemData,Howmany.Value)
end
DataStore:SetAsync(playerId.."Howmany",HowManyData)
DataStore:SetAsync(playerId.."ItemName",ItemData)
end)
and then
local script is this one.
local RemoteEvent = game.ReplicatedStorage.RemoteEvents.Shops
local slots = script.Parent
RemoteEvent.LoadItem.OnClientEvent:Connect(function(Howmany,Item)
for i = 1, 117 do
local slot = slots:FindFirstChild("Slot"..i)
local HowManyValue = slot:FindFirstChild("HowMany")
local ItemNameValue = slot:FindFirstChild("Itemname")
local count = slot:FindFirstChild("Count")
HowManyValue.Value = Howmany[i]
ItemNameValue.Value = Item[i]
print(HowManyValue.Value)
count.Text = Howmany[i]
HowManyValue = count.Text
end
end)
and the print result is this one,

Why the result are different?
and how to solve this problem