Hi Other Developers,
I’ve been trying to make a RNG game but why is my code giving a warning even though label is clearly visible?
Here is my code:
for _, label in pairs(RollGui.WhenRolledGUI:FindFirstChild("AllTexts"):GetChildren()) do
if label:IsA("TextLabel") and label.Visible == true then
local NewAuraInstance = BasicAuras[label.Name]:Clone()
print("Aura Created")
else
warn("Aura is not created for:" .. label.Name)
print(label.Visible)
end
end
Cloning an instance only creates the instance, but doesn’t parent it (the parent property is nil
Try extending the code which clones the aura, so it parents it correctly:
local NewAuraInstance = BasicAuras[label.Name]:Clone()
NewAuraInstance.Parent = RollGui.WhenRolledGUI.AllTexts -- you may need to change the parent instance.
print("Aura Created")
no the problem is that the code checks if the textlabel is visible, if it is the aura gets cloned and prints out “Aura Created”, but rn its warning “Aura is not created” even though the label is visible for me
Is the code in a server script or a local script?
Also, its possible that label:IsA("TextLabel") is what is evaluating to false, not the label.Visible thing
for _, label in pairs(RollGui.WhenRolledGUI:FindFirstChild("AllTexts"):GetChildren()) do
if label:IsA("TextLabel") and label.Visible then
local NewAuraInstance = BasicAuras[label.Name]:Clone()
print(NewAuraInstance)
local Constraint: WeldConstraint = Instance.new("WeldConstraint")
Constraint.Parent = NewAuraInstance
NewAuraInstance.CFrame = Player.Character.HumanoidRootPart.CFrame
Constraint.Part0 = Player.Character.HumanoidRootPart
Constraint.Part1 = NewAuraInstance
NewAuraInstance.Parent = Player.Character.HumanoidRootPart.AuraEquippedFolder
print("Aura Created")
elseif label:IsA("TextLabel") and not label.Visible then
warn("Aura is not created for:" .. label.Name)
print(label.Visible)
else
warn("Is not TextLabel")
end
end
I think it might be the loop being out of date but im not sure
Can you please have the code change something obvious on the textlabel, such as the background color or text color, at the same place that you warn that the label is not visible, to ensure that the text label you see is the one the code is saying is not visible.
the textlabel in the parent though are all textlabels because they are in the explorer tab, so I think its the visibilty false because I printed the visibility of all the labels and they all came back with false even though some are visible.
I can give you more of the script but its sorta hard to see
if i==5 then
task.wait(0.8)
task.spawn(function()
for i=0.5, 1, 0.01 do
Darkner.BackgroundTransparency = i
task.wait()
end
Darkner.BackgroundTransparency = 1
end)
local EquipButtonsParent: Frame = Darkner.Parent:WaitForChild("EquipButtons")
EquipButtonsParent.Visible = true
for _, childplaceholder in pairs(EquipButtonsParent:GetChildren()) do
if childplaceholder:IsA("TextButton") then
local Button: TextButton = childplaceholder
Button.Activated:Once(function()
if Button.Name == "Equip" then
print("Looped")
-- TODO (1. When Inventory System is Implanted it Will Check Whether Storage Is Full or Not)
if CurrentAurasEquipped > 0 then
if Player.Character.HumanoidRootPart:FindFirstChild("AuraEquippedFolder"):GetChildren()[1] == nil then
warn("Aura Is Nil to Destroy")
else
Player.Character.HumanoidRootPart:FindFirstChild("AuraEquippedFolder"):ClearAllChildren()
CurrentAurasEquipped -= 1
print(CurrentAurasEquipped)
end
end
CurrentAurasEquipped += 1
for _, label in pairs(RollGui.WhenRolledGUI:FindFirstChild("AllTexts"):GetChildren()) do
if label:IsA("TextLabel") and label.Visible then
local NewAuraInstance = BasicAuras[label.Name]:Clone()
print(NewAuraInstance)
local Constraint: WeldConstraint = Instance.new("WeldConstraint")
Constraint.Parent = NewAuraInstance
NewAuraInstance.CFrame = Player.Character.HumanoidRootPart.CFrame
Constraint.Part0 = Player.Character.HumanoidRootPart
Constraint.Part1 = NewAuraInstance
NewAuraInstance.Parent = Player.Character.HumanoidRootPart.AuraEquippedFolder
print("Aura Created")
elseif label:IsA("TextLabel") and not label.Visible then
warn("Aura is not created for: " .. label.Name)
print(label.Visible)
end
end
--[[
for _, AuraChild in pairs(AuraEquipped:GetDescendants()) do
local NewAuraInstance = AuraChild:Clone()
NewAuraInstance.Parent = Player.Character.HumanoidRootPart.AuraEquippedFolder
end
]]
EquipButtonsParent.Visible = false
for _, v in pairs(RollGui.WhenRolledGUI:FindFirstChild("AllTexts"):GetChildren()) do
if v:IsA("TextLabel") then
v.Visible = false
end
end
Looped = false
Rolling = false
return
elseif Button.Name == "Unequip" then
EquipButtonsParent.Visible = false
for _, v in pairs(RollGui.WhenRolledGUI:FindFirstChild("AllTexts"):GetChildren()) do
if v:IsA("TextLabel") then
v.Visible = false
end
end
print(CurrentAurasEquipped)
Looped = false
Rolling = false
return
else
warn("Nor Equip Button or Unequip was Activated")
end
end)
end
end
else
for _, v in pairs(RollGui.WhenRolledGUI:FindFirstChild("AllTexts"):GetChildren()) do
if v:IsA("TextLabel") then
v.Visible = false
end
end
end
so this code is in a loop in another loop in another loop thats in a function
Can you please carry out the test I mentioned in my previous post? As I can’t see the issue immediately, certain tests need to be carried out in order to identify the issue.