Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
nanaluk01 247 Moderation Voter
7 years ago
Edited 7 years ago

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

Log in to vote
0
Answered by
nanaluk01 247 Moderation Voter
7 years ago

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)
Ad
Log in to vote
-1
Answered by 7 years ago

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

0
I have.. it is just too long so it hops to the next line (only on this site) nanaluk01 247 — 7y
0
yea he has. he has a folder named the Player's Name inside of the Swords Folder RobloxianDestory 262 — 7y
0
ohh my bad :D csgoislove 0 — 7y

Answer this question