Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Won't clone frame?

Asked by 9 years ago

I am trying to make a SurfaceGui shop that gets all items in a Folder, clones the frame and changes the frame.ItemName(TextLabel).Text to the name of it. But for some reason I can't get this script to work.

local sp = script.Parent
local folder = sp.ScrollingFrame
local player = script.Parent.Parent.Parent.Parent

function refresh()
    folder:ClearAllChildren()
    for _,item in pairs(game.ServerStorage.ShopItems:GetChildren()) do 
        local frame = script.Frame:Clone()
        frame.Parent = folder
        frame.ItemName.Text = item.Name " : "..item.Price.Value..""
        frame.Name = item.Name
        frame.Purchase.MouseButton1Click:connect(function(c)
            if player:FindFirstChild("globalstats").Points.Value < item.Price.Value
                then
                return false
            else
                player:FindFirstChild("globalstats").Points.Value = player:FindFirstChild("globalstats").Points.Value - item.Price.Value
                local itemt = item.Tool:Clone()
                itemt.Parent = player.Backpack
                itemt.Name = item.Name
            end
        end)
    end
end

game.Players.PlayerAdded:connect(function(p)
    wait(1)
    refresh()
end)

Output show's no error's, can anyone tell me why it won't work?

0
Remove line 4 and try it. Discern 1007 — 9y
0
Nope, still won't work. ISellCows 2 — 9y
0
Try removing the argument "c" on line 12. Discern 1007 — 9y
0
xJasonn: Don't give speculative advice as comments. Submit an answer if you have a solution. BlueTaslem 18071 — 9y
View all comments (2 more)
0
Have you done any debugging? Have you checked that `refresh` is in fact called when a new player joins by seeing a `print` happen? BlueTaslem 18071 — 9y
0
Still does not work. ISellCows 2 — 9y

Answer this question