Starting Menu Script Doesn't work

Hello there users of devforum. I have made this script where you click a button and it’ll show a list of teams to join. Although So far it has worked. The camera script to change to the player when the player clicks a team doesn’t work and instead just returns to the part thats the camera.

I have tried re-arranging the code and more but none work so far. Any help/feedback?

Local Script


local RemoteEvent = game.ReplicatedStorage.TeamChange

local menubutton = script.Parent.IngameMenu:WaitForChild("MenuButton")

local menuchange = script.Parent.Frame

local frame = script.Parent:WaitForChild("Frame")

local gui = script.Parent
local PlayBtn = gui.PlayBtn

local ClassD = "Deep orange"
local MTF = "Bright blue"
local Security = "Pearl"

local camera = workspace.CurrentCamera

repeat
	wait()
	camera.CameraType = Enum.CameraType.Scriptable
	print(camera.CameraType)
until camera.CameraType

camera.CFrame = workspace.CameraFocusPart.CFrame

PlayBtn.MouseButton1Click:Connect(function()
	menuchange.Visible = true
end)

menuchange.Visible = false
script.Parent.IngameMenu.Visible = false

menubutton.MouseButton1Click:Connect(function()
	menuchange.Visible = true	
end)

frame["Class-D"].CD.MouseButton1Click:Connect(function()
	RemoteEvent:FireServer(BrickColor.new(ClassD))
	menuchange.Visible = false
	camera.CameraType = Enum.CameraType.Custom
end)


frame.Security.SD.MouseButton1Click:Connect(function()
	RemoteEvent:FireServer(BrickColor.new(Security))
	menuchange.Visible = false
end)

frame.MTF.MobileTask.MouseButton1Click:Connect(function()
	RemoteEvent:FireServer(BrickColor.new(MTF))
	menuchange.Visible = false
end)

Disable resetonspawn in the GUI’s properties

1 Like

I don’t see anything in the script that could possibly be causing this issue, but something like this would usually happen when the script runs more than once. What could be causing this is the Starting Menu ScreenGui has a property called ResetOnSpawn ticked to true and your server script respawns your character when you select a team, causing the GUI and all it’s descendants to reset (including the scripts).

1 Like

Yeah after taking the advice from the comment above this It works now thanks!