I have a folder in the player which contains which ‘Rides’ they own and I also have a GUI that contains frames that would correspond to each ride. I need it to check that the corresponding value to each GUI exists in the Rides folder, and if not it will show the ‘Locked’ button - but only for that one frame and not all of them. I would need it to check each one idividually.
In the simpliest way… If a boolValue inside of the rides folder exists with the same name as one of the GUI frames, remove the locked button, else show the locked button. Hopefully this makes sense.
Here is what I’ve tried so far
local player = game.Players.LocalPlayer
while true do
wait()
for _, frames in pairs(script.Parent:GetChildren()) do
for _, rides in pairs(player.Rides:GetChildren()) do
if frames.Name == rides.Name then
frames.Inner.Locked.Visible = false
elseif not frames.Name == rides.Name then
frames.Inner.Locked.Visible = true
end
end
end
end
Yeah its a local script inside the GUI. What do you need to see of the explorer?
I have just written this script which works, however only for the one ride. I would need it to do this process but loop through it until it has tried to match each frame in the GUI with each BoolValue in the ‘Rides’ folder
local player = game.Players.LocalPlayer
local Rides = player.Rides
while true do
wait()
if Rides:FindFirstChild("Extreme") then
script.Parent.Extreme.Inner.Locked.Visible = false
elseif not Rides:FindFirstChild("Extreme") then
script.Parent.Extreme.Inner.Locked.Visible = true
end
end
You can just use the else condition instead of elseif since else will work if the condition will be false.
By the way also you can directly use while task.wait() do if you dont have to put task.wait() inside the loop. wait() is deprecated so use task.wait() instead.
Yeah, being on phone atm i can’t fix your script, but don’t forget those optimizations.
I will try fix it later if not resolved by you or anyone else once ill be available. Goodluck.
Awesome - thank you! I’ve changed them all in my script, and I’ll keep trying things I can think of to see if it works, if not then hopefully you or someone else may be able to give a hand
Something to point out is that while true do or while wait/task.wait() do are not good on performance. while loops tell the code to do something while the given statement is false, but true and task.wait() are always going to prove to be true, which causes something called polling. Essentially it’s like asking the engine “Are we there yet?” every 1/60th of a second, which while task.wait() seems to fix on the surface, still will soon cause lag.
A lesser laggy solution is to event driven functions, such as frame:GetPropertyChangedSignal("Name"):Connect(function()
Laggy? It depends what do you put inside the loop. You use a loop when you constantly want to check or do something every X seconds, you use GetPropertyChangedSignal for specific situation and you dont want to yield the thread.
Im not correcting you entirely, just giving advice.
while task.wait() wouldnt make anything lag at anytime if its correctly used, example for A-Chassis using ~10 while true do and RunService events and scripts are working without anything break or create lags.
Thanks for this. To be most efficient I’m going to switch it to only update when the GUI is opened each time, so its not constantly checking for updates - even if this won’t have much of a performance impact.