Script decided to not work when duplicating a textbutton

Script:

for _,v in pairs(game.ServerStorage.SpawnableCars:GetChildren()) do
	local phsocool = script.Parent.Template:Clone()
	phsocool.Name = v.Name
	phsocool.Text = v.Name
	phsocool.Visible = true
end

but it doesn’t duplicate

explorer:
image

I don’t understand what you are doing, you have a loop in server storage yet you then use script.Parent.
There are multiple reasons why this won’t work as you haven’t placed it into their UI.

you cannot access serverstorage in a local script

I also tried doing this with a server script. it didn’t work.

I am very confused by what you are saying.

Is this a local script or a server script?

try moving the spawnableCars into replicatedstorage

OH I SEE you didnt set the parent lol

Ok, so first of all u cannot access stuff in serverstorage if its in a localscript so try moving the “spawnablecars” into replicatedstorage instead, also u didn’t set the parent of “phsocool”

for _,v in pairs(game.ReplicatedStorage.SpawnableCars:GetChildren()) do
	local phsocool = script.Parent.Template:Clone()
    phsocool.Parent = script.Parent
	phsocool.Name = v.Name
	phsocool.Text = v.Name
	phsocool.Visible = true
end
1 Like

Why would I need to set the parent? it is cloned under what I want it to be parented to which is frame.

I’d recommend parenting the clone after you customize it. Because sometimes it fails to edit the button (Very low chance of it happening, but just to stay safe).

1 Like

If you clone it, it only clones it. But it doesn’t set the parent. If you don’t set the parent then it’s parent will be nil, meaning it’s nowhere in the game.

1 Like

Oh, ok. thanks for telling me this!

1 Like

No, problem! We are always here to help others!

1 Like