I'm trying to create a script which when you click a button, it creates a textLabel in a Frame, but it doesn't work.
To detect the click and make a value which is placed inside the frame.
local example1 = script.Parent:FindFirstChild("Example1")
local example2 = script.Parent:FindFirstChild("Example2")
local function createAList(name,price)
local thing = Instance.new("StringValue",script.Parent.Parent.OrderFrame)
thing.Name = name
thing.Value = name.." : "..price
local pos = Instance.new("NumberValue",thing)
pos.Value = script.Parent.Parent.LocalLast.Value + 50
pos.Name = "Hello"
script.Parent.Parent.LocalLast.Value = script.Parent.Parent.LocalLast.Value + 50
end
example1.MouseButton1Click:connect(function()
script.Parent.Parent.Total.Text = "Total: "..script.Parent.Parent.Total.Total.Value + example1.Price.Value
script.Parent.Parent.Total.Total.Value = script.Parent.Parent.Total.Total.Value + example1.Price.Value
createAList(example1.Text,example1.Price.Value)
end)
example2.MouseButton1Click:connect(function()
script.Parent.Parent.Total.Text = "Total: "..script.Parent.Parent.Total.Total.Value + example2.Price.Value
script.Parent.Parent.Total.Total.Value = script.Parent.Parent.Total.Total.Value + example2.Price.Value
createAList(example2.Text,example2.Price.Value)
end)
Checks every time a child is added.
script.Parent.ChildAdded:connect(function()
for i,v in pairs(script.Parent:GetChildren()) do
if v.ClassName == "StringValue" then
local order = Instance.new("TextLabel",script.Parent)
order.Text = v.Value
wait()
order.Position = UDim2.new(0,0,0,v:FindFirstChild("Hello").Value)
end
end
end)
But when I try this, I get the error
17:09:22.353 - Maximum event re-entrancy depth exceeded for Instance.ChildAdded
17:09:22.353 - While entering function defined in script 'Players.Player1.PlayerGui.OrderGuiMobile.Screen.OrderFrame.Script', line 1
Any help will be appreciated!
