As a learning scripter, I’m sure i’m doing something wrong which can be fixed in a jiffy. Thats why i’ve turned to you guys, the DevForum!
This is my script:
-- Defining who is who and what is what
local Issues = script.Parent.Parent:FindFirstChild("Issues")--Gets the Issues folder
local IssueBearers = script.Parent.Parent:FindFirstChild("IssueBearer")-- Gets the IssueBearers folder.
-- Due to using script.parent:FindFirstChild("Issues"):GetChildren() returning an error, i'll instead do the stuff below!
local IssuesChildren = Issues:GetChildren()
local CurrentIssue = script.Parent.Parent:FindFirstChild("CurrentIssue")
local IssueBearerImage = script.Parent.Parent:FindFirstChild("IssuBearer")
script.Parent.MouseButton1Click:Connect(function()
local Ran = Random.new()
local IssueNow = IssuesChildren[Ran:NextInteger(1, #IssuesChildren)]
local BearerNow = IssueBearers[Ran:NextInteger(1, #IssueBearers)]
print(IssueNow)
print(BearerNow)
end)
The local Issues and IssueBearers are two folders inside of a GUI in StarterGui.
I was trying to randomize the issues and the people who brought those issues to you. And when this code is run, this is the error i get:
I’m quite confused by this error, so any help would be wonderful!
Thanks
I spotted it. The reason why it’s nil is because your :FindFirstChild() call isn’t returning anything, because you’ve made a minor typo in its name. ‘Issu’ should be ‘Issue’ I’m presuming.
Whats causing the error is on line 7, which is Issues:GetChildren(). As far as i’m aware,
local IssuesChildren = Issues:GetChildren()
does have children due to it being the name of the folder.
The typo down the line was intentional, since there is the name of the folder called IssueBearer, and the name of the button, which to differentiate from the folder was called IssuBearer.
So it doesn’t come up with an outright error, which is good, but instead gives me Infinite yield possible on ‘Players.coolkidtris.PlayerGui.randomize button:WaitForChild(“Issues”)’
i switched it to a localscript now, and its still either giving the error, or when changed to be WaitForChild, it still returns Infinite yield possible on ‘Players.coolkidtris.PlayerGui.randomize button:WaitForChild(“Issues”)’ when the button is clicked.