Hi. I am making a team fighting game, and I made a menu for it, which lets you select your team when a player stays in the menu until the next round, it should tween their camera to their character, but it doesn’t. ONLY HAPPENS WHEN YOU STAY IN THE MENU UNTIL THE NEXT ROUND.
A picture:
Here’s my code:
repeat
wait();
until game:IsLoaded();
script.Parent.Parent.Enabled = true;
local cameras = workspace:WaitForChild("Cameras")
local Camera = cameras:WaitForChild("Camera")
local TeamFrame = script.Parent;
local currentCamera = game.Workspace.CurrentCamera;
local player = game.Players.LocalPlayer;
if not player.Character then
player.CharacterAdded:Wait()
end
local character = player.Character
wait(.1)
currentCamera.CameraType = Enum.CameraType.Scriptable;
local currentOldCFrame = currentCamera.CFrame;
currentCamera.CFrame = Camera.CFrame
local playerModules = require(player:WaitForChild("PlayerScripts"):WaitForChild("PlayerModule"))
local controls = playerModules:GetControls()
controls:Disable()
local starterGUI = game:GetService("StarterGui")
starterGUI:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
pcall(function()
starterGUI:SetCore("ResetButtonCallback", false)
end)
local RunService = game:GetService("RunService")
local default = {Positions = {
Red = UDim2.new(0.261, 0,0.526, 0),
Blue = UDim2.new(0.261, 0,0.526, 0),
Play = UDim2.new(0.289, 0,0.146, 0)
}};
local TweenService = game:GetService("TweenService")
local replicatedStorage = game:GetService("ReplicatedStorage")
local Remotes = replicatedStorage:WaitForChild("Remotes")
local Choose = Remotes:WaitForChild("Choose")
local detectGame = Remotes:WaitForChild("DetectGame")
local SelectedTeam = replicatedStorage:WaitForChild("SelectedTeam")
local Selected = replicatedStorage:WaitForChild("Selected")
local GameStarted = replicatedStorage:WaitForChild("GameStarted")
local Stats = Remotes:WaitForChild("StatIncrease")
local currentTeamSelected = nil;
if currentCamera:FindFirstChildOfClass("BlurEffect") then
currentCamera:FindFirstChildOfClass("BlurEffect"):Destroy()
end
local blur = Instance.new("BlurEffect");
blur.Parent = currentCamera
for index, element in pairs(TeamFrame:GetChildren()) do
if element:IsA("TextButton") then
default[element] = element.Size
element.MouseButton1Down:Connect(function()
local track = TweenService:Create(element, TweenInfo.new(0.2, Enum.EasingStyle.Circular, Enum.EasingDirection.InOut, 0, false, 0), {Size = default.Positions[element.Name]})
track:Play()
end)
element.MouseButton1Up:Connect(function()
local track = TweenService:Create(element, TweenInfo.new(0.2, Enum.EasingStyle.Circular, Enum.EasingDirection.InOut, 0, false, 0), {Size = default[element]})
track:Play()
if element.Name ~= "Play" and element:FindFirstChild("Team") and SelectedTeam.Value == "" then
currentTeamSelected = element.Name;
TeamFrame.TeamSelected.Text = currentTeamSelected
elseif element.Name == "Play" then
if not currentTeamSelected and SelectedTeam.Value == "" then warn("Yes Return") return end;
if detectGame:InvokeServer() then
warn("Test1!")
if #game:GetService("Teams")[currentTeamSelected ~= nil and currentTeamSelected or SelectedTeam.Value ~= "" and SelectedTeam.Value]:GetPlayers() < 3 then
warn("Test2")
if SelectedTeam.Value == "" and not Selected.Value then
warn("Test3")
SelectedTeam.Value = currentTeamSelected
Selected.Value = true
end
else
warn("Test4")
TeamFrame.TeamSelected.Text = "Team is full"
TeamFrame.TeamSelected.TextColor3 = Color3.fromRGB(255, 0, 0)
wait(1.5)
TeamFrame.TeamSelected.Text = currentTeamSelected
TeamFrame.TeamSelected.TextColor3 = Color3.fromRGB(255, 255, 255)
return
end
warn("Test5")
blur:Destroy()
TweenService:Create(TeamFrame, TweenInfo.new(0.25, Enum.EasingStyle.Circular, Enum.EasingDirection.InOut, 0, false, 0), {Position = UDim2.new(0.5, 0, 1.3, 0)}):Play()
local trackTween = TweenService:Create(currentCamera, TweenInfo.new(1, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut, 0, false, 0), {CFrame = CFrame.new(character.HumanoidRootPart.CFrame.p)})
trackTween:Play()
trackTween.Completed:Wait()
currentCamera.CameraType = Enum.CameraType.Custom
TeamFrame.Timer.Visible = true
Choose:FireServer(SelectedTeam.Value)
starterGUI:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
controls:Enable()
else
starterGUI:SetCore("SendNotification", {
Title = "Game";
Text = "Intermission!";
Duration = 5;
})
end
end
end)
end
end
GameStarted:GetPropertyChangedSignal("Value"):Connect(function()
if GameStarted.Value then
-- Do nothing;
else
warn("Yes")
SelectedTeam.Value = ""
Selected.Value = false
currentTeamSelected = nil
end
end)
character:WaitForChild("Humanoid").Died:Connect(function()
Stats:FireServer("Deaths")
end)
RunService.RenderStepped:Connect(function()
if SelectedTeam.Value ~= "" then
for index, element in pairs(TeamFrame:GetChildren()) do
if element:FindFirstChild("Team") then
element.Visible = false;
end
end
TeamFrame.Message.Visible = true
else
TeamFrame.Message.Visible = false
for index, element in pairs(TeamFrame:GetChildren()) do
if element:FindFirstChild("Team") then
element.Visible = true;
end
end
end
end)
Help is very appreciated!
