UI Button won't go through?

Hi! I’ve been trying to get this button to go through for a while and I just can’t get it to work. It currently has prints everywhere and none of them get printed.

Any ideas?

for i,v in pairs(DispatchMF.Dashboard.Calls.Holder:GetChildren()) do

if not v:IsA("UIListLayout") then

	
		v.delete.MouseButton1Click:Connect(function()
	print("DeleteClicked")
	local callname = v.Name
	print("CallName Varred")
	Functions.RemoveCall(callname)
	print("SentFunction")
	end)
	
	end

end

Thank you!

1 Like

May I see the hierarchy of the DispatchMF.Dashboard.Calls.Holder?

The clean code here: no functional changes

for _, v in pairs(DispatchMF.Dashboard.Calls.Holder:GetChildren()) do
    if not v:IsA("UIListLayout") then
        v.delete.MouseButton1Click:Connect(function()
            Functions.RemoveCall(v.Name)
        end
    end
end
1 Like

Sure!

https://gyazo.com/c460e055b908abbb5e0c18c47c870efb

The code that creates another frame with the name is here:

Summary

For some reason, it won’t space 4 lines, it just goes on a new line. Im sorry!

game.ReplicatedStorage.ImprovedCAD.Events.CreateCall.OnClientEvent:Connect(function(callername, location, desc, id)
local clone = DispatchMF.Dashboard.Calls.Holder.call:Clone()
clone.callername.Text = callername
clone.desc.Text = desc
clone.Name = callername
clone.location.Text = location
clone.Parent = DispatchMF.Dashboard.Calls.Holder

end)

Cleaning code:

game.ReplicatedStorage.ImprovedCAD.Events.CreateCall.OnClientEvent:Connect(function(callername, location, desc, id)
	local clone = DispatchMF.Dashboard.Calls.Holder.call:Clone()
	
	clone.callername.Text = callername
	clone.desc.Text = desc
	clone.Name = callername
	clone.location.Text = location
	clone.Parent = DispatchMF.Dashboard.Calls.Holder
end)

Attempting solution:

for _, v in pairs(DispatchMF.Dashboard.Calls.Holder:GetChildren()) do
	local button = v:FindFirstChildWhichIsA("GuiButton")
	if button then
		button.MouseButton1Click:Connect(function()
			Functions.RemoveCall(v.Name)
		end)
	end
end

One problem is where all these GUI are placed.

1 Like

Can you provide me with a screenshot of the Output?

The console? Nothing happens… There’s just a lot of nothing relayed.

image

I tried your solution, but unfortunately nothing happens still.

I forgot to ask you about what the intended functionality of the button is. Functions.RemoveCall(v.Name) is a mystery to me. Can you forward the function?


I think you should add another function to the DispatchMF.Dashboard.Calls.Holder hooked to the ChildAdded listener. Because the buttons would otherwise be left non-functional.

DispatchMF.Dashboard.Calls.Holder.ChildAdded:Connect(function(child)
	local button = child:FindFirstChild("delete")
	if button then
		button.MouseButton1Click:Connect(function()
			Functions.RemoveCall(child.Name)
		end)
	end
end

@BxPanxi Updated.

1 Like
Function
module.RemoveCall = function(callname)
print("GotRemoveCall")
	Events:WaitForChild("DeleteCall"):FireServer(callname)
print("FiredEvent")
end
Script the function fires
game.ReplicatedStorage.ImprovedCAD.Events.DeleteCall.OnServerEvent:Connect(function(plr, callname)
print("GotDeleteCall")
	game.ReplicatedStorage.ImprovedCAD.Events:WaitForChild("DeleteCall"):FireAllClients(callname)
print("FiredAllClients")
end)

–This goes to the first script in the post.

Worked! Thank you for your help!