My problem is that it does not let me create more data from stringValue on line 81, I already tried everything and it gives me an error
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
local Lighting = game:GetService("Lighting")
local graficos = ReplicatedStorage:WaitForChild("Graficos")
local MyDataStore = DataStoreService:GetDataStore("MyDataStore")
local shadowSettings = {
Bajo = function(player: Player)
player:WaitForChild("PlayerGui"):WaitForChild("MenuDeMapa"):WaitForChild("Sombras").Abrir.Text = " Bajo"
player:WaitForChild("PlayerGui"):WaitForChild("MenuDeMapa"):WaitForChild("Sombras"):WaitForChild("Abrir"):WaitForChild("Visible"):WaitForChild("Botones"):WaitForChild("Bajo").Frame.Visible = true
player:WaitForChild("PlayerGui"):WaitForChild("MenuDeMapa"):WaitForChild("Sombras"):WaitForChild("Abrir"):WaitForChild("Visible"):WaitForChild("Botones"):WaitForChild("Medio").Frame.Visible = false
player:WaitForChild("PlayerGui"):WaitForChild("MenuDeMapa"):WaitForChild("Sombras"):WaitForChild("Abrir"):WaitForChild("Visible"):WaitForChild("Botones"):WaitForChild("Alto").Frame.Visible = false
end,
Medio = function(player: Player)
player:WaitForChild("PlayerGui"):WaitForChild("MenuDeMapa"):WaitForChild("Sombras").Abrir.Text = " Medio"
player:WaitForChild("PlayerGui"):WaitForChild("MenuDeMapa"):WaitForChild("Sombras"):WaitForChild("Abrir"):WaitForChild("Visible"):WaitForChild("Botones"):WaitForChild("Bajo").Frame.Visible = false
player:WaitForChild("PlayerGui"):WaitForChild("MenuDeMapa"):WaitForChild("Sombras"):WaitForChild("Abrir"):WaitForChild("Visible"):WaitForChild("Botones"):WaitForChild("Medio").Frame.Visible = true
player:WaitForChild("PlayerGui"):WaitForChild("MenuDeMapa"):WaitForChild("Sombras"):WaitForChild("Abrir"):WaitForChild("Visible"):WaitForChild("Botones"):WaitForChild("Alto").Frame.Visible = false
end,
Alto = function(player:Player)
player:WaitForChild("PlayerGui"):WaitForChild("MenuDeMapa"):WaitForChild("Sombras").Abrir.Text = " Alto"
player:WaitForChild("PlayerGui"):WaitForChild("MenuDeMapa"):WaitForChild("Sombras"):WaitForChild("Abrir"):WaitForChild("Visible"):WaitForChild("Botones"):WaitForChild("Bajo").Frame.Visible = false
player:WaitForChild("PlayerGui"):WaitForChild("MenuDeMapa"):WaitForChild("Sombras"):WaitForChild("Abrir"):WaitForChild("Visible"):WaitForChild("Botones"):WaitForChild("Medio").Frame.Visible = false
player:WaitForChild("PlayerGui"):WaitForChild("MenuDeMapa"):WaitForChild("Sombras"):WaitForChild("Abrir"):WaitForChild("Visible"):WaitForChild("Botones"):WaitForChild("Alto").Frame.Visible = true
end,
}
local waterSettings = {
Bajo = function(player: Player)
player:WaitForChild("PlayerGui"):WaitForChild("MenuDeMapa"):WaitForChild("AguaCalidad").Abrir.Text = " Bajo"
player:WaitForChild("PlayerGui"):WaitForChild("MenuDeMapa"):WaitForChild("AguaCalidad"):WaitForChild("Abrir"):WaitForChild("Visible"):WaitForChild("Botones"):WaitForChild("Bajo").Frame.Visible = true
player:WaitForChild("PlayerGui"):WaitForChild("MenuDeMapa"):WaitForChild("AguaCalidad"):WaitForChild("Abrir"):WaitForChild("Visible"):WaitForChild("Botones"):WaitForChild("Medio").Frame.Visible = false
player:WaitForChild("PlayerGui"):WaitForChild("MenuDeMapa"):WaitForChild("AguaCalidad"):WaitForChild("Abrir"):WaitForChild("Visible"):WaitForChild("Botones"):WaitForChild("Alto").Frame.Visible = false
end,
Medio = function(player: Player)
player:WaitForChild("PlayerGui"):WaitForChild("MenuDeMapa"):WaitForChild("AguaCalidad").Abrir.Text = " Medio"
player:WaitForChild("PlayerGui"):WaitForChild("MenuDeMapa"):WaitForChild("AguaCalidad"):WaitForChild("Abrir"):WaitForChild("Visible"):WaitForChild("Botones"):WaitForChild("Bajo").Frame.Visible = false
player:WaitForChild("PlayerGui"):WaitForChild("MenuDeMapa"):WaitForChild("AguaCalidad"):WaitForChild("Abrir"):WaitForChild("Visible"):WaitForChild("Botones"):WaitForChild("Medio").Frame.Visible = true
player:WaitForChild("PlayerGui"):WaitForChild("MenuDeMapa"):WaitForChild("AguaCalidad"):WaitForChild("Abrir"):WaitForChild("Visible"):WaitForChild("Botones"):WaitForChild("Alto").Frame.Visible = false
end,
Alto = function(player:Player)
player:WaitForChild("PlayerGui"):WaitForChild("MenuDeMapa"):WaitForChild("AguaCalidad").Abrir.Text = " Alto"
player:WaitForChild("PlayerGui"):WaitForChild("MenuDeMapa"):WaitForChild("AguaCalidad"):WaitForChild("Abrir"):WaitForChild("Visible"):WaitForChild("Botones"):WaitForChild("Bajo").Frame.Visible = false
player:WaitForChild("PlayerGui"):WaitForChild("MenuDeMapa"):WaitForChild("AguaCalidad"):WaitForChild("Abrir"):WaitForChild("Visible"):WaitForChild("Botones"):WaitForChild("Medio").Frame.Visible = false
player:WaitForChild("PlayerGui"):WaitForChild("MenuDeMapa"):WaitForChild("AguaCalidad"):WaitForChild("Abrir"):WaitForChild("Visible"):WaitForChild("Botones"):WaitForChild("Alto").Frame.Visible = true
end,
}
game.Players.PlayerAdded:Connect(function(player: Player)
local graficosFol = Instance.new("Folder")
graficosFol.Name = "Graficos"
graficosFol.Parent = player
local graphicsBools = {
{type = "StringValue", name = "Shadow"},
{type = "StringValue", name = "Water"},
-- Add more values for your graphics folder!
--{tipo = "String Value", nombre = "Nombre de la configuraciĂłn"},
}
for _, value in pairs(graphicsBools) do
local val = Instance.new(value.type)
val.Name = value.name
val.Parent = graficosFol
end
local data
local succes: boolean, errormessage: string = pcall(function()
data = MyDataStore:GetAsync(player.UserId.."Value")
end)
if (succes) then
-- Si ya hay datos
if (data) then
-- Puede establecer más valores si lo desea
player:WaitForChild("Graficos"):WaitForChild("Shadow").Value = data.shadow
shadowSettings[data.shadow](player)
player:WaitForChild("Graficos"):WaitForChild("Water").Value = data.water
waterSettings[data.water](player)
else
-- Sin datos, proporcione datos predeterminados para comenzar
player:WaitForChild("Graficos"):WaitForChild("Shadow").Value = "Medio"
shadowSettings.Medio(player)
player:WaitForChild("Graficos"):WaitForChild("Water").Value = "Medio"
waterSettings.Medio(player)
end
else
print("Se ha producido un error al guardar datos")
warn(errormessage)
end
end)
graficos.ChangeSetting.OnServerEvent:Connect(function(player: Player, setting: string, value: string)
if (not player.Graficos:FindFirstChild(setting)) then return end
if (not shadowSettings[value]) then return end
player.Graficos[setting].Value = value
shadowSettings[value](player)
if (not player.Graficos:FindFirstChild(setting)) then return end
if (not waterSettings[value]) then return end
player.Graficos[setting].Value = value
waterSettings[value](player)
end)
game.Players.PlayerRemoving:Connect(function(player: Player)
local values = {
-- Get all the values!
shadow = player.Graficos.Shadow.Value,
water = player.Graficos.Water.Value
}
local success: boolean, errormessage: string = pcall(function()
MyDataStore:SetAsync(player.UserId .. "Value", values)
end)
if (success) then
print("Se ha guardado correctamente")
else
print("hubo un error al guardar")
warn(errormessage)
end
end)