Alright, so I made my title screen script and I tested it in Roblox Studio, and it worked while using the simulation mode there (It launched the title screen and showed the fixed camera without showing the player character/having to reset).
But when I went to the actual place (outside of studio) and tested it, the character spawned first, and the camera showed the player, without the camera getting in position OR the title screen popping up. I looked through but I don't know what's wrong with it. When I reset the character, the script's actions then executed. I need the script to execute the first time, without requiring the player to be reset. The script is located in StarterGui and it's a LocalScript. Help would be appreciated!
The Script:
--[[ Player ]]
local player = game.Players.LocalPlayer
player.Character.Humanoid.WalkSpeed = 0
--[[ Fixed Camera ]]
local cam = workspace.CurrentCamera
local CameraLocation = Vector3.new(-22.5, 35.5, -58.5)
local CameraDirection = Vector3.new(-8, 4.5, -92)
local fixedcam1 = true
cam.CameraType = "Scriptable"
game["Run Service"].RenderStepped:connect(function()
if fixedcam1 == true then
cam.CoordinateFrame = CFrame.new(CameraLocation,CameraDirection)
end
end)
--[[ Title Screen ]]
local titlescreen = Instance.new("ScreenGui")
titlescreen.Parent = script.Parent
titlescreen.Name = "TitleScreen"
-- Frame
local titleframe = Instance.new("Frame")
titleframe.Name = "TitleFrame"
titleframe.Parent = titlescreen
titleframe.Position = UDim2.new(0.08, 0, 0.01, 0)
titleframe.Size = UDim2.new(.85, 0, .85, 0)
titleframe.Style = "RobloxRound"
-- Text
local titletext = Instance.new("TextLabel")
titletext.Name = "TitleText"
titletext.Parent = titlescreen
titletext.TextColor3 = Color3.new(170, 0, 0)
titletext.Position = UDim2.new(0.4, 0, 0.085, 0)
titletext.Size = UDim2.new(0.25, 0, 0.1, 0)
titletext.FontSize = "Size24"
titletext.BackgroundTransparency = 1
titletext.Text = "Project Undefined"
-- Button
local titlebutton = Instance.new("TextButton")
titlebutton.Name = "TitleButton"
titlebutton.Parent = titlescreen
titlebutton.Position = UDim2.new(0.4, 0, 0.35, 0)
titlebutton.Size = UDim2.new(0.25, 0, 0.1, 0)
titlebutton.BackgroundColor3 = Color3.new(144, 0, 0)
titlebutton.FontSize = "Size14"
titlebutton.Text = "Start"
-- MouseClick
function onClicked()
titlescreen:Destroy()
player.Character.Humanoid.WalkSpeed = 16
fixedcam1 = false
cam.CameraSubject = player.Character.Humanoid
cam.CameraType = "Custom"
end
titlebutton.MouseButton1Down:connect(onClicked)
Thanks in advance!
