I know, my scripts made by me are full of errors, and that is why I come to ask you gods of the Olympus for help.
Well my problem is that the following script should detect a StringValue value when pressing a text button, it works but does not work when exiting and re-entering. If I have a datastore that loads the values, but the script doesn’t detect the values, and I’ve had this problem many times already.
This is the first part of the script that sends the information to a Fire to a remote event and thus detects it in the datastore
local Botones = script.Parent:WaitForChild("Botones")
local Falso = script.Parent:WaitForChild("Falso")
local text = script.Parent.Parent:WaitForChild("CantidadDeBrillo")
local volumen1 = Botones:WaitForChild("a")
local volumen2 = Botones:WaitForChild("b")
local volumen3 = Botones:WaitForChild("c")
local volumen4 = Botones:WaitForChild("d")
local volumen5 = Botones:WaitForChild("e")
local volumen6 = Botones:WaitForChild("f")
local volumen7 = Botones:WaitForChild("g")
local volumen8 = Botones:WaitForChild("h")
local volumen9 = Botones:WaitForChild("i")
local volumen10 = Botones:WaitForChild("j")
local Fire = game:WaitForChild("ReplicatedStorage"):WaitForChild("ConfiguracionGeneral"):WaitForChild("JuegoConfg")
local TimeFalse = 0.5
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local AnimateUI = require(ReplicatedStorage:WaitForChild("ConfiguracionGeneral"):WaitForChild("JuegoConfg"):WaitForChild("BrilloText"))
local Nivel = script.Parent:WaitForChild("Nivel")
--Posicion volumen5 predeterminada
volumen1.MouseButton1Click:Connect(function()
local textMessage = [[0.1]]
AnimateUI.typeWrite(text, textMessage, 0.05)
Nivel:TweenPosition(UDim2.new(-0.4, 0, 0, 0), nil, nil, 0.3)
game:GetService("Lighting").Brightness = 1.2
game:GetService("Lighting").Ambient = Color3.new(0.207843, 0.207843, 0.207843)
Botones.Visible = false
Falso.Visible = true
wait(TimeFalse)
Botones.Visible = true
Falso.Visible = false
Fire.BrilloVol:FireServer("BrilloVol", "BrilloVolumen1")
end)
volumen2.MouseButton1Click:Connect(function()
local textMessage = [[0.2]]
AnimateUI.typeWrite(text, textMessage, 0.05)
Nivel:TweenPosition(UDim2.new(-0.3, 0, 0, 0), nil, nil, 0.3)
game:GetService("Lighting").Brightness = 1.4
game:GetService("Lighting").Ambient = Color3.new(0.329412, 0.329412, 0.329412)
Botones.Visible = false
Falso.Visible = true
wait(TimeFalse)
Botones.Visible = true
Falso.Visible = false
Fire.BrilloVol:FireServer("BrilloVol", "BrilloVolumen2")
end)
volumen3.MouseButton1Click:Connect(function()
local textMessage = [[0.3]]
AnimateUI.typeWrite(text, textMessage, 0.05)
Nivel:TweenPosition(UDim2.new(-0.2, 0, 0, 0), nil, nil, 0.3)
game:GetService("Lighting").Brightness = 1.6
game:GetService("Lighting").Ambient = Color3.new(0.403922, 0.403922, 0.403922)
Botones.Visible = false
Falso.Visible = true
wait(TimeFalse)
Botones.Visible = true
Falso.Visible = false
Fire.BrilloVol:FireServer("BrilloVol", "BrilloVolumen3")
end)
volumen4.MouseButton1Click:Connect(function()
local textMessage = [[0.4]]
AnimateUI.typeWrite(text, textMessage, 0.05)
Nivel:TweenPosition(UDim2.new(-0.1, 0, 0, 0), nil, nil, 0.3)
game:GetService("Lighting").Brightness = 1.8
game:GetService("Lighting").Ambient = Color3.new(0.47451, 0.47451, 0.47451)
Botones.Visible = false
Falso.Visible = true
wait(TimeFalse)
Botones.Visible = true
Falso.Visible = false
Fire.BrilloVol:FireServer("BrilloVol", "BrilloVolumen4")
end)
volumen5.MouseButton1Click:Connect(function()
local textMessage = [[0.5]]
AnimateUI.typeWrite(text, textMessage, 0.05)
Nivel:TweenPosition(UDim2.new(0, 0, 0, 0), nil, nil, 0.3)
game:GetService("Lighting").Brightness = 2
game:GetService("Lighting").Ambient = Color3.new(0.541176, 0.541176, 0.541176)
Botones.Visible = false
Falso.Visible = true
wait(TimeFalse)
Botones.Visible = true
Falso.Visible = false
Fire.BrilloVol:FireServer("BrilloVol", "BrilloVolumen5")
end)
volumen6.MouseButton1Click:Connect(function()
local textMessage = [[0.6]]
AnimateUI.typeWrite(text, textMessage, 0.05)
Nivel:TweenPosition(UDim2.new(0.1, 0, 0, 0), nil, nil, 0.3)
game:GetService("Lighting").Brightness = 2.2
game:GetService("Lighting").Ambient = Color3.new(0.631373, 0.631373, 0.631373)
Botones.Visible = false
Falso.Visible = true
wait(TimeFalse)
Botones.Visible = true
Falso.Visible = false
Fire.BrilloVol:FireServer("BrilloVol", "BrilloVolumen6")
end)
volumen7.MouseButton1Click:Connect(function()
local textMessage = [[0.7]]
AnimateUI.typeWrite(text, textMessage, 0.05)
Nivel:TweenPosition(UDim2.new(0.2, 0, 0, 0), nil, nil, 0.3)
game:GetService("Lighting").Brightness = 2.4
game:GetService("Lighting").Ambient = Color3.new(0.737255, 0.737255, 0.737255)
Botones.Visible = false
Falso.Visible = true
wait(TimeFalse)
Botones.Visible = true
Falso.Visible = false
Fire.BrilloVol:FireServer("BrilloVol", "BrilloVolumen7")
end)
volumen8.MouseButton1Click:Connect(function()
local textMessage = [[0.8]]
AnimateUI.typeWrite(text, textMessage, 0.05)
Nivel:TweenPosition(UDim2.new(0.3, 0, 0, 0), nil, nil, 0.3)
game:GetService("Lighting").Brightness = 2.6
game:GetService("Lighting").Ambient = Color3.new(0.839216, 0.839216, 0.839216)
Botones.Visible = false
Falso.Visible = true
wait(TimeFalse)
Botones.Visible = true
Falso.Visible = false
Fire.BrilloVol:FireServer("BrilloVol", "BrilloVolumen8")
end)
volumen9.MouseButton1Click:Connect(function()
local textMessage = [[0.9]]
AnimateUI.typeWrite(text, textMessage, 0.05)
Nivel:TweenPosition(UDim2.new(0.4, 0, 0, 0), nil, nil, 0.3)
game:GetService("Lighting").Brightness = 2.8
game:GetService("Lighting").Ambient = Color3.new(0.917647, 0.917647, 0.917647)
Botones.Visible = false
Falso.Visible = true
wait(TimeFalse)
Botones.Visible = true
Falso.Visible = false
Fire.BrilloVol:FireServer("BrilloVol", "BrilloVolumen9")
end)
volumen10.MouseButton1Click:Connect(function()
local textMessage = [[1.0]]
AnimateUI.typeWrite(text, textMessage, 0.05)
Nivel:TweenPosition(UDim2.new(0.485, 0, 0, 0), nil, nil, 0.3)
game:GetService("Lighting").Brightness = 3
game:GetService("Lighting").Ambient = Color3.new(1, 1, 1)
Botones.Visible = false
Falso.Visible = true
wait(TimeFalse)
Botones.Visible = true
Falso.Visible = false
Fire.BrilloVol:FireServer("BrilloVol", "BrilloVolumen10")
end)
This is the second part of the same script, to make it easier for you to understand.
local StringValueObject = game.Players.LocalPlayer:WaitForChild("JuegoConfg"):WaitForChild("BrilloVol")
StringValueObject.Changed:Connect(function()
if StringValueObject.Value == "BrilloVolumen1" then
game:GetService("Lighting").Brightness = 1.2
game:GetService("Lighting").Ambient = Color3.new(0.207843, 0.207843, 0.207843)
end
if StringValueObject.Value == "BrilloVolumen2" then
game:GetService("Lighting").Brightness = 1.4
game:GetService("Lighting").Ambient = Color3.new(0.329412, 0.329412, 0.329412)
end
if StringValueObject.Value == "BrilloVolumen3" then
game:GetService("Lighting").Brightness = 1.6
game:GetService("Lighting").Ambient = Color3.new(0.403922, 0.403922, 0.403922)
end
if StringValueObject.Value == "BrilloVolumen4" then
game:GetService("Lighting").Brightness = 1.8
game:GetService("Lighting").Ambient = Color3.new(0.47451, 0.47451, 0.47451)
end
if StringValueObject.Value == "BrilloVolumen5" then
game:GetService("Lighting").Brightness = 2
game:GetService("Lighting").Ambient = Color3.new(0.541176, 0.541176, 0.541176)
end
if StringValueObject.Value == "BrilloVolumen6" then
game:GetService("Lighting").Brightness = 2.2
game:GetService("Lighting").Ambient = Color3.new(0.631373, 0.631373, 0.631373)
end
if StringValueObject.Value == "BrilloVolumen7" then
game:GetService("Lighting").Brightness = 2.4
game:GetService("Lighting").Ambient = Color3.new(0.737255, 0.737255, 0.737255)
end
if StringValueObject.Value == "BrilloVolumen8" then
game:GetService("Lighting").Brightness = 2.6
game:GetService("Lighting").Ambient = Color3.new(0.839216, 0.839216, 0.839216)
if StringValueObject.Value == "BrilloVolumen9" then
game:GetService("Lighting").Brightness = 2.8
game:GetService("Lighting").Ambient = Color3.new(0.917647, 0.917647, 0.917647)
end
if StringValueObject.Value == "BrilloVolumen10" then
game:GetService("Lighting").Brightness = 3
game:GetService("Lighting").Ambient = Color3.new(1, 1, 1)
end
end
end)