Hi! I recently came back to roblox and am going through an old game and going to finish it as I gave up on it. Anyways, I am having to redo a lot of stuff and I need to add the name of a border that is bought to a table.
local remoteEvent = game.ReplicatedStorage.BuyArea
local areaDataStore = game:GetService("DataStoreService"):GetDataStore("BorderSave")
for _, border in pairs(workspace.Borders:GetChildren()) do
if border:IsA("Part") then
border.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
print(border.Name.." was touched!")
local character = hit.Parent
local player = game.Players:GetPlayerFromCharacter(character)
player.AreaSelected.Value = border.Name
player.PlayerGui.BuyArea.Enabled = true
local price = game.Workspace.Borders.Area7Border.Price
player.PlayerGui.BuyArea.Body.TextBox.TextLabel.Text = "Would you like to buy " .. dataScript[border.Name].." for ".. workspace.Borders[border.Name].Price.Value.."?"
end
end)
end
end
local boughtData = {}
game:GetService("Players").PlayerRemoving:Connect(function(player) -- Checking if player is leaving game
local Success, Error = pcall(function()
return game:GetService("DataStoreService"):GetDataStore("BorderSave"):SetAsync(player.UserId.."Borders", boughtData)
-- Setting the data for inventory for the player
end)
if Error then
warn(Error) -- Showing there was error (Can also keep in log to fix)
end
end)
remoteEvent.OnServerEvent:Connect(function(player, border)
if player.leaderstats.Coins.Value >= workspace.Borders[border].Price.Value then
local Success, Error = pcall(function()
table.insert(boughtData, 1, border)
return game:GetService("DataStoreService"):GetDataStore("BorderSave"):SetAsync(player.UserId.."Borders", boughtData)
-- Setting the data for inventory for the player
end)
if Error then
warn(Error) -- Showing there was error (Can also keep in log to fix)
end
else
print("Not Enough Money!")
end
end)
I’m pretty sure its making the table but I am not sure if it is adding anything INTO the table.