Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why aren't text and image buttons responding?

Asked by 6 years ago

I am making a shop gui for my game using filtering enabled, however when I move my mouse over the button in studio the button does not respond, it just stays white.

Here's my local script:

local OpenGui = game:GetService('ReplicatedStorage').Remote.GuiOpen

script.Parent.MouseButton1Click:Connect(function()
    OpenGui:FireServer('shopMainFrame')
end)

And my server scipt:

function openGui(player, gui)
    game.Players:WaitForChild(player.name).PlayerGui.Guis.ScreenGui:WaitForChild(gui).Visible = not game.Players:WaitForChild(player.name).PlayerGui.Guis.ScreenGui:WaitForChild(gui).Visible
end

game:GetService('ReplicatedStorage').Remote.GuiOpen.OnServerEvent:Connect(function(player, gui)
    openGui(player, gui)
end)

My StarterGui looks like this:
https://imgur.com/a/nZpIt

And here is what my guis look like when the mouse is over them: https://imgur.com/SVUrGS0

2 answers

Log in to vote
0
Answered by 6 years ago

Do your images have transparent backgrounds? When Roblox darkens your button on mouse hover it is actually the background that is getting darker, not the image. So if your images are opaque the color change will not be visible behind the image. To fix this, either use images with transparency, or if you cant/don't want to then you can use something like this to get the same effect:

local button = script.Parent
local defaultButtonColor = button.ImageColor3
local hoverButtonColor = Color3.new(0.8, 0.8, 0.8)

button.MouseEnter:connect(function()
    button.ImageColor3 = hoverButtonColor
end)

button.MouseLeave:connect(function()
    button.ImageColor3 = defaultButtonColor
end)
0
I've added this script and yet when I try hovering over the button nothing happens. My buttons do have pictures with transparent backgrounds, and even if I make a new test or image button neither respond. little1gaming 0 — 6y
0
However when I create a new place with the same security settings a text button works. little1gaming 0 — 6y
0
I cant think of a reason why it would work in one place and not another. Is it possible you have a transparent UI element covering the buttons that is blocking the mouse events? vector3_zero 1056 — 6y
0
I've played around with the gui and I've discovered that it works on it's own when some other element(That I haven't pinned down yet) is implemented in to the new place. I'll test around some more and see if I can narrow it down. little1gaming 0 — 6y
View all comments (2 more)
0
I think I figured it out, for some reason the players service was still active in the explorer even after the test was ended. Now I'm not sure on this one but this leads me to believe that that PlayerGui object was not being updated for events. I made a new place and copied everything in except for the old gui (which I remade for the new place just in case) and now it works. little1gaming 0 — 6y
0
That is strange, but great news that you have it working :) vector3_zero 1056 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

Server Scripts cannot access PlayerGuis, only LocalScripts.

LocalScript

local guiHere -- Location of  the gui that you want to open

script.Parent.MouseButton1Click:Connect(function()     
    guiHere.Visible = not guiHere.Visible
end)

Answer this question