Hello, Im trying to make a menu system for the first time and have came into a roadblock of a problem that I tried looking up the answer to and couldnt find anything… I am trying to enable the gui and music through a local script, but it isnt working neither is wait:().
Help is appreciated
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local playerGui = player.PlayerGui
local mouse = player:GetMouse()
local camera = workspace.CurrentCamera
local MenuCamera = workspace:WaitForChild("MenuCamera")
local MenuGui = playerGui:WaitForChild("MainMenuGui")
player.CharacterAdded:Connect(function(character)
wait(10)-- Wait for 10 seconds
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = MenuCamera.CFrame
MenuGui:wait()
MenuGui.Enabled = true
MenuGui.MenuMusic:Play()
end)
nope nothing happens… What weird is I have a wiggle script and the one local script only works when the other one is enable and they have no correlation to them. something has to be bugged.
Hmm, that’s weird. I also just noticed on line 16 that you tried to do “:wait()” on the MenuGui. wait() does not exist so that may be stopping the script from working. Try removing that line.
I removed that nothing happened, my scripts are located in starterplayerscripts. I tried move the scripts around and nothing happens. I think a bug is happening because the first script isnt working, but if I open the second one it works on that one.
first one:
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local playerGui = player.PlayerGui
local camera = workspace.CurrentCamera
local MenuCamera = workspace:WaitForChild("MenuCamera")
local MenuGui = playerGui:WaitForChild("MainMenuGui")
player.CharacterAdded:Connect(function(character)
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = MenuCamera.CFrame
-- Enable the GUI and play the music after the wait time
MenuGui.Enabled = true
MenuGui.MenuMusic:Play()
end)
second one:
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse()
local camera = workspace.CurrentCamera
local MenuCamera = workspace:WaitForChild("MenuCamera")
repeat
wait()
camera.CameraType = Enum.CameraType.Scriptable
until camera.CameraType == Enum.CameraType.Scriptable
-- Move cam
local maxTilt = 5
game:GetService("RunService").RenderStepped:Connect(function()
camera.CFrame = MenuCamera.CFrame * CFrame.Angles(
math.rad((((mouse.Y - mouse.ViewSizeY / 2) / mouse.ViewSizeY)) * -maxTilt),
math.rad((((mouse.X - mouse.ViewSizeX / 2) / mouse.ViewSizeX)) * -maxTilt),
0
)
end)
Oooooo iw found an error while disabling one of the scripts. It seems to be a cloud problem .
cloud_6514761722.UITools.Main.source.tools.properties:434: attempt to index number with ‘Value’ - Edit
21:10:22.689 Stack Begin - Studio
21:10:22.689 Script ‘cloud_6514761722.UITools.Main.source.tools.properties’, Line 434 - function set - Studio
21:10:22.689 Script ‘cloud_6514761722.UITools.Main.source.tools.properties’, Line 446 - function refresh - Studio
21:10:22.689 Stack End - Studio
21:10:22.919 cloud_6514761722.UITools.Main.source.tools.properties:434: attempt to index number with ‘Value’ - Edit
21:10:22.919 Stack Begin - Studio
21:10:22.919 Script ‘cloud_6514761722.UITools.Main.source.tools.properties’, Line 434 - function set - Studio
21:10:22.919 Script ‘cloud_6514761722.UITools.Main.source.tools.properties’, Line 446 - function refresh - Studio
21:10:22.919 Stack End - Studio
Let’s see if removing the CharacterAdded event will do anything.
In the code below, the CharacterAdded event is removed and instead, we replace it with when the game is fully loaded.
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local playerGui = player.PlayerGui
local camera = workspace.CurrentCamera
local MenuCamera = workspace:WaitForChild("MenuCamera")
local MenuGui = playerGui:WaitForChild("MainMenuGui")
game.Loaded:Connect(function()
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = MenuCamera.CFrame
-- Enable the GUI and play the music after the wait time
MenuGui.Enabled = true
MenuGui.MenuMusic:Play()
end)
That did the same thing ughhhh, I updated the script and the menu is still not getting enabled…
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local playerGui = player.PlayerGui
local camera = workspace.CurrentCamera
local MenuCamera = workspace:WaitForChild("MenuCamera")
local mouse = player:GetMouse()
local MenuGui = playerGui:WaitForChild("MainMenuGui")
game.Loaded:Connect(function()
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = MenuCamera.CFrame
-- Enable the GUI and play the music after the wait time
MenuGui.Enabled = true
MenuGui.MenuMusic:Play()
end)
repeat
wait()
camera.CameraType = Enum.CameraType.Scriptable
until camera.CameraType == Enum.CameraType.Scriptable
-- Move cam
local maxTilt = 5
game:GetService("RunService").RenderStepped:Connect(function()
camera.CFrame = MenuCamera.CFrame * CFrame.Angles(
math.rad((((mouse.Y - mouse.ViewSizeY / 2) / mouse.ViewSizeY)) * -maxTilt),
math.rad((((mouse.X - mouse.ViewSizeX / 2) / mouse.ViewSizeX)) * -maxTilt),
0
)
end)