GUI mouse functions not working when theres more than 2 applied to the gui?

When I add the MouseEnter/MouseLeave functions on my Gui, it works just fine. But when on top of that I add a MouseButton1Click function, they all stop working. Why is this happening? Thanks!

The code:
local Play = script.Parent.Parent.PlayButton

local Settings = script.Parent.Parent.SettingsButton

local Changelog = script.Parent.Parent.ChangelogButton

local Gamepass = script.Parent.Parent.GamepassButton

script.Parent.MouseLeave:Connect(function()

script.Parent:TweenPosition(UDim2.new(0.048, 0,0.608, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, .5, true)

end)

script.Parent.MouseEnter:Connect(function()

script.Parent:TweenPosition(UDim2.new(0.123, 0,0.608, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, .5, true)

end)

script.Parent.MouseButton1Click:Connect(function()

game.Workspace.StartGameValue.Value = 1

end)

1 Like

Can you check if there are any errors in the output?

No, there are no errors, it should be working.

try adding prints between each function and see if they run or not.

I added the print function and the weirdest thing occured. So when you click it, it changes a value in the workspace to 1. Another script reads it and if the value is 1 it will run. I made sure that when you click it the value is 1, it looks like this script is the problem, why is it not working right?

Script location: StarterPlayer > StarterplayerScripts
Script:
local guiLocation = game.StarterGui.TitleScreenButtons
local Camera = game.workspace.CurrentCamera

while true do
wait(1)
if game.Workspace.StartGameValue == 1 then
local Info = TweenInfo.new(1)
local Tween = game:GetService(“TweenService”):Create(script.Parent.Parent.Fade,Info,{BackgroundTransparency=0})
Tween:Play()
wait(1.5)
game.Workspace.UnfreezeValue.Value = 1
game.Workspace.TitleScreenMusicPlaying.Value = 1
game.Lighting.Blur.Size = 0
guiLocation.SideBar.Visible = false
guiLocation.PlayButton.Visible = false
guiLocation.SettingsButton.Visible = false
guiLocation.ChangelogButton.Visible = false
guiLocation.GamepassButton.Visible = false
Camera.CameraType = Enum.CameraType.Custom
wait(1.5)
local Info = TweenInfo.new(1)
local Tween = game:GetService(“TweenService”):Create(script.Parent.Parent.Fade,Info,{BackgroundTransparency=1})
Tween:Play()
else
print(“Not Ready.”)
end
end

MouseButton1Click is only an event of GuiButtons. Make sure you’re not using a Frame or some other type of Gui Element that can fire this event.

Sorry my DevForum was down, just saw this. I’m using an ImageButton, that works right?

script.Parent.MouseButton1Click:Connect(function()

game.Workspace.StartGameValue.Value = 1

end)

Are you sure you want to execute the code inside the function locally?

If your goal is to set the StartGameValue for the whole server, you should use a server event. Otherwise the value only changes for the player that clicked the GUI, and the change is not passed onto the server for its scripts to handle that.

No, this is for the title screen, I want it to only activate for the person who clicked it.

Honestly there shouldn’t be a while loop in the first place. You should put all the code inside that if statement inside the function that handles the mouse click:

if game.Workspace.StartGameValue == 1 then ... -- Put the code inside this if statement into your MouseButton1Click handler

Ah, just figured it out. It’s a bit hard to explain but it was my fault not the codes lol.