Try understanding what someone said before you reply on it.
You know what, I’m just gonna go to roblox studio and try to recreate this scenario.
local valuestable = clonedAlumian.MoveSets:GetChildren()
for _ , e in pairs(script.Parent.Parent.encounterGui.Options:GetChildren()) do
if e:IsA("TextLabel") then
chosenvalue = valuestable[math.random(1,#valuestable)]
e.Text = chosenvalue.Name
table.remove(valuestable , valuestable[chosenvalue])
end
end
I am sorry but for once can you try this?
Woah, that looks pretty complicated and I especially don’t like that math.random in there, doesn’t look like good practice. I bet the answer is simple, just gotta find it.
Just a few questions I need to know before recreating this in roblox studio:
- Are the GUI buttons in starterGUI?
- Where is the script located and is it a local or server script?
- Where is the folder containing the attacks located?
- Yes
- script is located in a screengui
- the folder containing the attacks is located in the “clonedAlumian”
Ah for some reason I don’t know it seems the chosen value did not get removed.
So the screenGUI is located inside of StarterGUI? Also you didn’t answer if it’s a local or server script.
Also what is clonedAlumian and where is that.
it’s a local script and clonedAlumian is in a pets folder in replicatedstorage
But what object is ClonedAlumian itself? is it a model or folder? Remember I need to know the full context here.
a model.
Alright. I’m recreating in roblox studio. Also how did you reply with a short message?
i just used this: ```
eeeeeeeee
Wait I just realized the problem, but I don’t quite know the solution.
You put a for loop inside of a for loop.
I will use numbers 1 2 3 4 for examples instead of the attack names.
So basically, the system will find the first button called button 1.
Then it will loop through all of the attack name values 1-4.
What happens is that it sets the button name to 1, then 2, then 3, then finally 4. It does it so fast it looks like it just gets instantly set to 4.
Then it does the same thing for all the other buttons, which explains why they all have the same name.
Yea I think thats the problem aswell
Maybe a code example:
local AttackNumber = 0
local AttackMovesets = clonedAlumian.MoveSets:GetChildren()
for i,v in pairs(script.Parent.Parent.encounterGui.Options:GetChildren()) do
if v:IsA("TextButton") then
AttackNumber += 1
v.Text = AttackMovesets[AttackNumber].Name
end
end