Team change GUI camera manipulation problems makes the game UNPLAYABLE

I’ve tried making a team change GUI where you spawn into the game, and you are looking over a baseplate. That bit works, but when you change your team I want the camera manipulation to go away and the player to be in normal camera mode. Instead though when you change your team you are still looking over that same baseplate and you can’t even see your player. I’ve tried fixing it but to no avail. Here is the script:

local TeamChoose = script.Parent.Parent
local confirm = script.Parent.Parent.Teamchange.Frame.Light.Button
local confirm2 = script.Parent.Parent.Teamchange.Frame.Dark.TextButton

local Camera = game.Workspace.CurrentCamera
local Player = game.Players.LocalPlayer

repeat wait() until Player.Character

repeat wait()
    Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable
Camera.CFrame = game.Workspace.CamPart.CFrame


confirm.MouseButton1Click:Connect(function()
    Camera.CameraSubject = Player.Character:WaitForChild("Humanoid")
end)

confirm2.MouseButton1Click:Connect(function()
    Camera.CameraSubject = Player.Character.Humanoid
end)

Thanks for your help.
NOTE: I get absolutely no errors.

You need to set the camera type back to Enum.CameraType.Custom in order for the camera to follow the camerasubject.

1 Like

Im quite new to scripting, so where would I put that in the script?

You would change the confirm.MouseButton1Click:Connect() function to this:

confirm.MouseButton1Click:Connect(function()
    repeat wait()
		Camera.CameraType = Enum.CameraType.Custom
	until Camera.CameraType == Enum.CameraType.Custom
    Camera.CameraSubject = Player.Character:WaitForChild("Humanoid")
end)

This is the same for the other button doing this behaviour

1 Like

I tried it but because when you press the team change button you die and respawn you just go back to the camera manipulation.

Would it be worth me adding my team change script as well to this? Well here it is. There are two of these scripts, one for each team.

local Camera = game.Workspace.CurrentCamera
local player = script.Parent.Parent.Parent.Parent.Parent
local TeamChoose = script.Parent.Parent
local Player = game.Players.LocalPlayer


script.Parent.MouseButton1Click:Connect(function()
	script.Parent.TextButton.Visible = false
	script.Parent.TextButton.Visible = true
end)


	
script.Parent.TextButton.MouseButton1Click:Connect(function()
	player.Team = game.Teams.Dark
	TeamChoose:TweenPosition(UDim2.new(0.25, -0,-1, -0),"Out","Quint",1,true)
	player.Character.Humanoid.Health = 0
end)

Does the script run whenever the player is spawned? That’s probably the problem. I haven’t worked with teams, but why do you need to reset the player to change the team? If you need to respawn the player on a spawn pad, it would be easiest just to set the CFrame of their HumanoidRootPart then, or change your camera script not to run every time the player spawns

EDIT: By “the script” I meant the camera script in the first sentence

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.TextButton.Visible = false
	script.Parent.TextButton.Visible = true
end)

Why? This won’t change nothing, i think instead of that, do this:

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.TextButton.Visible = not script.Parent.TextButton.Visible
end)

Yeah my script runs whenever a player spawns.
Note: And if u die any other way I don’t want you to keep going back to the camera manipulation.

In the camera script, you could only set the camera to orbit the baseplate if the player doesn’t have a team. I believe there’s a Player.Team property?
For example, the script could only run if the player’s team is nil.

Also, what is the type of script you are using? And where?

Well, it does say that when you are on no team you are on the “neutral” team by default. How would I go about making it that the camera manipulation only happens when you are on the neutral team?

For the camera script Im using a local script in a screen Gui inside starter Gui and for the team one its a script in a textbutton, which is in a frame, which is in a screenGUI which is in starter gui

1 Like
local plr = game.Players.LocalPlayer

if plr.Team = Neutral or nil then
    --code
end
1 Like

There is a Player.Neutral property, so you can check if the player is Neutral instead of on a team. My bad.

Pheonix, would I put that in the camera script?

I guess you should do what synoot said, but in response to your question, yes.

Pheonix, in that code that you gave me would I just disable the camera script if the player is in neutral or nil team?

The or is something from the script, its not to you edit it, just stay with it like that.

Actually let me test something…