Attempt to index nil with 'Clone' (line 3)

local Obbies = game:GetService("ReplicatedStorage"):WaitForChild("Obbies")

local ChosenObby = Obbies:FindFirstChild(math.random(1,#Obbies:GetChildren())):Clone()
ChosenObby.Parent = workspace

Yes, I checked the and the folder itself with the obbies is there

You’re using FindFirstChild and trying to use it like it’s a table index.

Try this instead

local ObbiesAvailable = Obbies:GetChildren()
local ChosenObby = ObbiesAvailable[math.random(1,#ObbiesAvailable]:Clone()
ChosenObby.Parent = workspace

FindFirstChild expects a string; the name of the object you are trying to get. It will find the first child in the instance with that name. And unless the names of all of the obbies are numbers, your original code with not work properly.

dont i need to clone the obby tho?

1 Like

That was a mistake on my part. My bad… lol. I just changed it.

local Obbies = game:GetService("ReplicatedStorage"):WaitForChild("Obbies")

local ChosenObby = Obbies[math.random(1,#Obbies:GetChildren()]:Clone()
ChosenObby.Parent = workspace

Can it be this? Bc I want to also make a dev product to change the obby but i dont need help with that

You would just need to add :GetChildren() to the end of this line

Then change this to #Obbies instead of #Obbies:GetChildren()

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.