-
What do you want to achieve? I want to create a main menu (with a surface gui)
-
What is the issue? The problem is, that the MouseButton1Click function wont detect any clicks
-
What solutions have you tried so far? I experimented with different code structures but nothing I tried seemed to work.
Explorer:
Script:
local players = game:GetService("Players")
local rps = game:GetService("ReplicatedStorage")
local rs = game:GetService("RunService")
local sg = game:GetService("StarterGui")
local uis = game:GetService("UserInputService")
local player = players.LocalPlayer
local playerGui = player.PlayerGui
local menuGuis = sg.Menu
local mainMenu = menuGuis.MainMenu:Clone()
mainMenu.Parent = playerGui
local RemotesFolder = rps:WaitForChild("Remotes")
local Camera = workspace.CurrentCamera
local menuFolder = workspace:WaitForChild("Menu")
local cameraParts = menuFolder:WaitForChild("CameraParts")
Camera.CameraType = Enum.CameraType.Scriptable
local playButtonPressed = Instance.new("BoolValue")
playButtonPressed.Name = "PlayButtonPressed"
playButtonPressed.Value = false
playButtonPressed.Parent = playerGui:WaitForChild("Menu")
local GoTo = Instance.new("StringValue")
GoTo.Value = "MainMenu"
GoTo.Name = "GoTo"
GoTo.Parent = Camera
Camera.CFrame = cameraParts[GoTo.Value].CFrame
local NewScreenGui = Instance.new("ScreenGui", playerGui)
local TextButton = Instance.new("TextButton")
TextButton.BackgroundTransparency = 1
TextButton.Size = UDim2.new(0, 0, 0, 0)
TextButton.Text = " "
TextButton.Parent = NewScreenGui
TextButton.Modal = true
local playButton = sg.Menu.MainMenu.PlayButton
rs.RenderStepped:Connect(function()
if playButtonPressed.Value == false then
local GoToPosition = cameraParts[GoTo.Value].CFrame
GoToPosition += Vector3.new(math.cos(tick() * 2) * 0.1, math.sin(tick() * 2) * 0.1, math.cos(tick() * 2) * 0.1)
Camera.CFrame = Camera.CFrame:Lerp(GoToPosition, 1)
else
end
end)
--// Player Model \\--
local playerModel = players:CreateHumanoidModelFromUserId(player.UserId)
playerModel.Parent = menuFolder.PlayerPart
playerModel:ScaleTo(1.5)
playerModel:PivotTo(menuFolder.PlayerPart.CFrame)
playerModel.Parent = menuFolder.PlayerPart
playButton.MouseButton1Click:Connect(function()
print("Mouse has been clicked")
playButtonPressed.Value = true
Camera.CameraType = Enum.CameraType.Custom
uis.MouseBehavior = Enum.MouseBehavior.LockCenter
TextButton:Destroy()
menuFolder:Destroy()
menuGuis:Destroy()
end)
--// Buttons \\--
--[[
local function regButton(Button: ImageButton)
Button.MouseButton1Click:Connect(function()
GoTo.Value = Button.Name
end)
end
]]--
-- This part is out-commented because i dont need it rn
Thank you for your time! I appreciate and kind of help.