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
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
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.
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