I am trying to make a morph inventory gui. But there is one problem, buttons in scrolling frame won't work.
Here is the code :
for i, v in pairs(script.Parent:GetChildren()) do v.MouseButton1Click:Connect(function() print("clicked") end) end
Once i click the button, it doesn't print "clicked"
the local script is a child of the scrolling frame. I have a spin system that gives players a character. After the spin, it will be directed to the inventory (scrolling frame).
Here is a snip of the code :
local function addChartoFrame(character) local clone = template:Clone() clone.Name = character.Name clone.name.Text = character.Name clone.Parent = frame local newChar = character:Clone() newChar.Parent = clone.ViewportFrame local cam = Instance.new("Camera") cam.CFrame = newChar.Head.CFrame * CFrame.Angles(0, math.rad(180), 0) * CFrame.new(0,0,2.5) cam.Parent = clone.ViewportFrame clone.ViewportFrame.CurrentCamera = cam end
The template in "template:Clone()" is a text button in the replicated storage
for i, v in pairs(script.Parent:GetChildren()) do if v:IsA'TextButton' then -- because the script is inside the scrolling frame, it will error at the script because MouseButton1Click wont work on the script, you need to make sure its only getting the buttons v.MouseButton1Click:Connect(function() print("clicked") end) end end