#waiting for a value

1 messages · Page 1 of 1 (latest)

distant vale
#

Hey! I was making a selection UI for a game and I ran into this problem where my ui is getting the value before its loaded by the data store, I was wondering if theres a way to wait for it to load the value? I also tried using a repeat untill but it doesnt work.

(Heres my code if maybe I did something wrong.)

local Slots = game.Players.LocalPlayer:WaitForChild("TrollSlots")
for i,v in Slots:GetChildren() do
    local NewSlot = script.Parent["0"]:Clone()
    NewSlot.Visible = true
    NewSlot.Name = string.char(i)
    local Name = v.Value
    NewSlot.Parent = script.Parent.loading
    NewSlot.TextLabel.Text = "Slot "..i.." - "..Name
end
task.wait()
for i,v in script.Parent.loading:GetChildren() do
    v.Parent = script.Parent
end

Again, Im just asking if theres a way to wait for it to load.

It's meant to say the value in the slot ("Troll") like "Slot # - Troll"

#

this is what it should look like btw

bitter remnant
#

Set a value to nil and do repeat wait() until value ~= nil

#

Then after the load part in the data script set the value to something else

#

You can also use boolvalues and other stuff

#

Kind of a redneck approach tho

distant vale
#

yeah i tried that with the repeat thing but its not nil "" or " " so im just using a tast.wait at the start for until i find a better solution

bitter remnant
#

Alr so what youre saying is that it loads it before the data can load?

#

Can you print the data for me?

#

Like in the gui script

distant vale
#

now it works when i do that

#

bro what 😭

#

print(Name) just fixes it

#

now its not

bitter remnant
#

Alr so

#

Can you send full code?

#

@distant vale

#

In ss form

#

Im mobile so hard to read

distant vale
#

i made new code to load when the ui is toggled

bitter remnant
#

So it works?

distant vale
#

yes

bitter remnant
#

Alr gl!

distant vale
#

ty

spiral estuary
#

cant we just use waitforchild?

bitter remnant
solemn crater
#

what value?

bitter remnant
spiral estuary
#

then we say if the value isnt loaded we are waiting for the value to be changed and then run the code

bitter remnant
solemn crater
#

waitforchild wait for the value to load already?

bitter remnant
#

Repeat wait() until isString(v.Value)

spiral estuary
#

we should just do v.Changed:Connect() idk why that shouldnt work

bitter remnant
solemn crater
#

v:GetPorpertyChangedSignal("Value"):Connect()

spiral estuary
solemn crater
#

local v: StringValue
local Name

if v.Value then
Name = v.Value
else
local singal

signal = v:GetPropertyChangedSignal("Value"):Connect(function()
    if not v.Value then return end
    
    Name = v.Value
    
    signal:Disconnect()
    signal = nil
end)

end

spiral estuary
distant vale
solemn crater
#

ok singal

distant vale
#

i already fixed it in a way that lets me change it so i can change the values and it changed