Clicking An ImageButton Does Not Work

When I click the image button nothing happens, “hello” prints but “hi” does not. No errors are shown in the output. This script is in PlayerScripts. Thanks.

local player = game.Players.LocalPlayer

local button = workspace.Model.Model.WoodenChest.WoodenChestBillBoardGui.BillboardGui.ImageButton

local replicatedStorage = game:GetService("ReplicatedStorage")

local RemoteEvent2 = game.ReplicatedStorage.RemoteEvent2

print("hello")

button.MouseButton1Click:Connect(function()

print("hi")

RemoteEvent2:FireServer()

end)

use the .Activated event.

button.Activated:Connect(function()

print("hi")

RemoteEvent2:FireServer()

end)

Additionally, if you are using billboard guis, place them in the PlayerGui and set the Adornee to the part you want to have the ui on.

1 Like

It’s still not working, the same thing happens. This is what I changed my script to. I also put BillboardGui in StarterGui

local player = game.Players.LocalPlayer

local button = game.StarterGui.BillboardGui.ImageButton

local replicatedStorage = game:GetService("ReplicatedStorage")

local RemoteEvent2 = game.ReplicatedStorage.RemoteEvent2

print("hello")

button.Activated:Connect(function()

print("hi")

RemoteEvent2:FireServer()

end)

You need to access the PlayerGui from there, so it’d be:

local button = player.PlayerGui.BillboardGui.ImageButton

The StarterGui holds an unaltered version of the user interface which is replicated into the PlayerGui. Each specific player’s user interface is under their player in an object called PlayerGui

1 Like

So first place BillBoardGui in PlayerGui and place the script in PlayerGui Too and change the script to this

local player = game.Players.LocalPlayer

local button = script.Parent.BillboardGui.ImageButton

local replicatedStorage = game:GetService("ReplicatedStorage")

local RemoteEvent2 = game.ReplicatedStorage.RemoteEvent2

print("hello")

button.MouseButton1Click:Connect(function()

print("hi")



end)

in line 3 game.StarterGui like @briact said it Wont do anything because it is not the player’s Current gui to do that you could do Player.PlayerGui or place the script in StarterGui and do script.Parent Like i did what im trying to say is that game.StarterGui is not the Player’s Current gui but Player.PlayerGui is if you would like to ask anything im happy to help :smiley:.

2 Likes