I was trying to make a LocalScript where the template clones every time there were children in ReplicatedStorage but however, but it did not do anything.
local template = script.Parent.ScrollingFrame.Template for _, items in pairs(game:GetService("ReplicatedStorage").Cars:GetChildren()) do local newtemplate = template:Clone() newtemplate.Name = items.Name print("run") newtemplate.Car.Value = items.Name newtemplate.Text = items.Name newtemplate.MouseButton1Click:Connect(function() local script = newtemplate local car = newtemplate.Car.Value if script.Parent.Purchased.Value == true then game.ReplicatedStorage.SpawnCar:FireServer(car) else if game.Players.LocalPlayer.leaderstats.Cash.Value >= game.ReplicatedStorage.CheckPrice:InvokeServer(car) then game.Players.LocalPlayer.leaderstats.Cash.Value = game.Players.LocalPlayer.leaderstats.Cash.Value - game.ReplicatedStorage.CheckPrice:InvokeServer(car) script.Parent.Purchased.Value = true game.ReplicatedStorage.SpawnCar:FireServer(car) end end script.Parent.Parent.Visible = false end) newtemplate.LocalScript:Destroy() print("run") end
I used the Run and Play in Studio but both did not function. The script type is a LocalScript located in StarterGui. Nothing has ever been printed at all. I expect it to rename the text of it and clone it. I tried to use GetChildren and GetDescendants but both don't work.