Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

[SOLVED]How would I find the first value that has a value set to false, and then change it?

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)

2 answers

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 :)

3 comments

0

I have.. it is just too long so it hops to the next line (only on this site)

0

yea he has. he has a folder named the Player's Name inside of the Swords Folder

0

ohh my bad :D

This discussion is preserved as it was. New answers, comments, and votes are closed.