How would I find the first value that has a value set to false, and then change it?
So... I have a script, where I need to find the first value in a set of values inside TextBoxes
I have tried a lot of things, but I can't get the value ("ChangeValue",see code) to change to true
I am going to shorten down the script to only what that series of code uses to find and change that value.
Any help is greatly appreciated.
Please note: prevname
is a value I have already set in some other script that also runs stuff for me
Please note: the children in SwordsButtons
all have a number as their name
Please note: Occupied is also a value (Boolean value) I have previously set in some other script
There are 0 errors
Shortened-down-code: (There might be some spelling mistakes, I wrote this in by hand, not copy paste)
local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() local PlrGui = Player.PlayerGui local StoreSword = PlrGui:FindFirstChild("SwordStore") local SwBackground = StoreSword.Background local SwordsButtons = SwBackground.Swords local PlayerSwordFolder = game.ReplicatedStorage.Swords:WaitForChild(Player.Name) local Number = game.ReplicatedStorage.Swords.Number local numberswords = PlayerSwordFolder:WaitForChild("NumberSwords") Mouse.Button2Up:connect(function() if numberswords.Value < 24 then numberswords.Value = numberswords.Value + 1 swordtostore.Name = swordtostore.prevname.Value .. numberswords.Value local ChangeValue = SwordsButtons:FindFirstChild(numberswords.Value).Occupied.Value == false ChangeValue = true end end)
I figured it out guys... if anyone is interested here is what I did
local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() local PlrGui = Player.PlayerGui local StoreSword = PlrGui:FindFirstChild("SwordStore") local SwBackground = StoreSword.Background local SwordsButtons = SwBackground.Swords local PlayerSwordFolder = game.ReplicatedStorage.Swords:WaitForChild(Player.Name) local Number = game.ReplicatedStorage.Swords.Number local numberswords = PlayerSwordFolder:WaitForChild("NumberSwords") Mouse.Button2Up:connect(function() if numberswords.Value < 24 then numberswords.Value = numberswords.Value + 1 swordtostore.Name = swordtostore.prevname.Value .. numberswords.Value local RePlaced = false for i,v in ipairs(SwordsButtons:GetChildren()) do if v.Occupied.Value == false then if RePlaced == false then v.Occupied.Value = true RePlaced = true print(v.Name) v.BackgroundColor3 = Color3.fromRGB(0,128,0) v.id.Value = swordtostore.Name end end end RePlaced = false end end)
Idk if you noticed but in line 7 you haven't finished the var. However I haven't read the whole code so, sorry if I miss anything :)