Hello, I was working on my game and I decided to start creating the “Play” button for my game. What I wanted to achieve was that the player’s camera moved from one block to another and meanwhile the Play button, the other menu buttons and the game title became invisible, and that worked perfectly but now when I press the “Play” button nothing happens anymore. I have reviewed all my code and I don’t understand why it doesn’t work anymore. I also realized that from line 53 onwards the script no longer works (that’s where the “Play” button part is). There is no error in the Output.
I have used a LocalScript which is located in ‘StarterGui’ and a ModuleScript which is also located in ‘StarterGui’, it’s my first time using a ModuleScript, I think that’s why it doesn’t work.
Module Script:
local StarterGui = game:GetService("StarterGui")
local TweenService = game:GetService("TweenService")
local Player = game:GetService("Players")
local LobbyScreenUI = StarterGui.LobbyScreenUI
-- Buttons
local PlayButton = LobbyScreenUI.PlayButton
local SettingsButton = LobbyScreenUI.SettingsButton
local CreditsButton = LobbyScreenUI.CreditsButton
-- Player Cam
local camera = workspace.CurrentCamera
Connection = camera:GetPropertyChangedSignal("CameraType"):Connect(function()
if camera.CameraType ~= Enum.CameraType.Scriptable then
camera.CameraType = Enum.CameraType.Scriptable
end
end)
camera.CameraType = Enum.CameraType.Scriptable
--// camera.CFrame = CameraStart.CFrame
local UImodule = {}
function UImodule:Clicked()
print("Play Button Clicked!")
local Tween = TweenService:Create(camera, TweenInfo.new(2.5), {["CFrame"] = workspace.StartingGameCam.CFrame})
Tween:Play()
end
function UImodule:DisableCoreGuiType()
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
end
function UImodule:EnableCoreGuiType()
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, true)
end
return UImodule
Local Script:
-- Services
local Player = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local StarterGui = game:GetService("StarterGui")
local CameraStart = workspace:WaitForChild("LobbyPlrCam")
local camera = workspace.CurrentCamera
-- Needed Modules
local UI_Module = require(StarterGui.UI_Scripts:WaitForChild("UI_Module"))
-- Change player camera to Scriptable
Connection = camera:GetPropertyChangedSignal("CameraType"):Connect(function()
if camera.CameraType ~= Enum.CameraType.Scriptable then
camera.CameraType = Enum.CameraType.Scriptable
end
end)
-- Change player camera CFrame to CameraStart in workspace
print("Player Camera is now Scriptable")
UI_Module:DisableCoreGuiType()
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = CameraStart.CFrame
-- Remove Connection When Done -> 'Connection:Disconnect'
-- LobbyUI objects
local LobbyUI = StarterGui.LobbyScreenUI
local PlayButton = LobbyUI.PlayButton
local SettingsButton = LobbyUI.SettingsButton
local CreditsButton = LobbyUI.CreditsButton
local GameTitle = LobbyUI.GameTitle
local PlayButton_UIStroke = PlayButton.UIStroke
local CreditsButton_UIStroke = CreditsButton.UIStroke
local SettingsButton_UIStroke = SettingsButton.UIStroke
local SettingsImageLabel = SettingsButton.ImageLabel
-- IntermissionUI objects
local IntermissionUI = StarterGui.IntermisionUI
local IntermissionFrame = IntermissionUI.IntermissionFrame
local IntermissionText = IntermissionFrame.IntermissionText
local Intermission_UIstroke = IntermissionFrame.UIStroke
-- MapSelectionUI objects
local MapSelectionBackgroundFrame = IntermissionUI.MapSelectionBackgroundFrame
local MapSelectionBackground_UIstroke = MapSelectionBackgroundFrame.UIStroke
local ChaptersFolder = MapSelectionBackgroundFrame.MapSelectionBoxFrame:WaitForChild("Chapters")
-- Function when player clicks "Play" button
PlayButton.MouseButton1Click:Connect(function()
UI_Module:Clicked() -- UImodule script
print("Button Clicked (Local Script)")
for _, UI in pairs({PlayButton, SettingsButton, CreditsButton, PlayButton_UIStroke, CreditsButton_UIStroke, SettingsButton_UIStroke}) do
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
local tween = TweenService:Create(UI, tweenInfo, {Transparency = 1})
local GameNameUITween = TweenService:Create(GameTitle, tweenInfo, {TextTransparency = 1})
local SettingsImageTween = TweenService:Create(SettingsImageLabel, tweenInfo, {ImageTransparency = 1})
tween:Play()
GameNameUITween:Play()
SettingsImageTween:Play()
end
task.wait(2.5)
script.Parent.IntermisionUI.Enabled = true
end)
Help highly appreciated!