this code is supposed to fire a remote event when the player clicks an Image button but it doesn’t work for some reason I have tried putting it in a function still doesn’t work.
local a = 0
for _, Button2 in pairs(UI.SurgeryUI:GetChildren()) do
a = a + 1
print(a)
if Button2:IsA("GuiButton") then
print("Button")
Button2.Activated:Connect(function()
print("Pressed")
game.ReplicatedStorage.RemoteEvents.ChatRemote:FireServer(Button2.Name)
end)
end
end
print(a) works
print(“Button”) works
but it doesn’t print(“Pressed”) when I press the button.
btw this for loop is inside another for loop
for _, Button in pairs(UI.ui:GetChildren()) do
if Button:IsA("GuiButton") then
Button.Activated:Connect(function()
-- the code above
end)
end
end
for _, Button in pairs(UI.ui:GetChildren()) do
if Button:IsA("GuiButton") then
Button.MouseButton1Down:Connect(function()
-- the code above
end)
end
end
Roblox has a specific function for a computer mouse which is called MouseButton. The touch-enabled devices don’t have a mouse so the only way you can determine a click is by touch. It just doesn’t make any sense to me if that would work either.
There was some misinformation/misleading information in the responses you got, .Activated works on all platforms and so do mouse related events as of now because the engineers have set it up to do that but it won’t stay like that so it’s suggested you use .Activated.
In response of the actual question in this post, are the buttons active (it’s a property)? I’ve had problems just like this plenty of times and that usually ended up being my problem.