Recently I’ve posted about a problem I’ve had with ‘DataStore’ stuff. The problem was that the script that was supposed to save the current value of the ‘StringValue’ connected to the ‘TextButton’ and when you rejoin the game, the ‘StringValue’ was supposed to have the value that was set in the last time you joined the game. However that didn’t go really well, tried so many solutions for 1 hour and still did not get it to work properly. I want to forget that script now and if possible, work on a completely different script. Though I’m really bad at scripting in general so I need your help too with this!
I threw away some buttons in a brand new place for testing purposes before putting them into my original game. As I’ve somewhat explained earlier, my goal is to switch between two buttons (as seen below). When you click one of them, the other’s ‘Visible’ property would be set to ‘false’ and the opposite would happen for the other button. There also should be a ‘StringValue’ so whenever you click on one of the buttons, the value would change to what the Button’s Text would say.
This is the current layout of my explorer tab. You click on ‘TextButton’, it would switch to ‘TextButtonLol’ and same would happen with ‘TextButtonLol’. The ‘ButtonOptions’ script handles this. The code below shows what that script contains:
local button1 = script.Parent.TextButton
local button2 = script.Parent.TextButtonLol
local CurrentButtonValue = game.Players.LocalPlayer.SettingsValues.CurrentButtonValue
button1.MouseButton1Click:Connect(function()
if CurrentButtonValue.Value == "L" then
CurrentButtonValue.Value = "Bozo"
button1.Visible = false
button2.Visible = true
end
end)
button2.MouseButton1Click:Connect(function()
if CurrentButtonValue.Value == "Bozo" then
CurrentButtonValue.Value = "L"
button1.Visible = true
button2.Visible = false
end
end)
I did not add the ‘StringValue’ yet into my explorer because I’m not too sure if I would have to add it with the script that would save the data (MenuSettings) like how I’ve done with the script that failed me basically at this point or could I just add the ‘StringValue’ now and just change the actual value of it in-game.
If you can help me with this I would be really pleased because it looks like I’m gonna need the ‘DataStore’ stuff a lot to complete my game and it would be good to learn the best ways possible.
Thank you!