Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

SOLVED Game is literally unplayable with these team change camera issues?

Asked by 4 years ago
Edited 4 years ago

Ive been trying to make a team change gui, where when you first join the game you are looking over a baseplate, due to camera manipulation. Then when you change the team, you spawn with the normal roblox camera and no camera manipulation. That second part does not work. The issue is that when I join a team my camera is not following the player- I cant even see the player on the screen. Here are the scripts

-- Camera 
local TeamChoose = script.Parent.Parent
local confirm = script.Parent.Parent.Teamchange.Frame.Light.Button --Select button
local confirm2 = script.Parent.Parent.Teamchange.Frame.Dark.TextButton --Select button

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

repeat wait() until Player.Character

Camera.CameraType = "Scriptable"
Camera.CFrame = game.Workspace.CamPart.CFrame


confirm.MouseButton1Click:Connect(function()
    Camera.CameraType = "Custom"
    game.Workspace.CamPart:Destroy()
end)

confirm2.MouseButton1Click:Connect(function()
    Camera.CameraType = "Custom"
    game.Workspace.CamPart:Destroy()
end)

And the team change (there are two of these, one for each team)

local Camera = game.Workspace.CurrentCamera
local Player = game.Players.LocalPlayer
local player = script.Parent.Parent.Parent.Parent.Parent
local TeamChoose = script.Parent.Parent
local confirm = script.Parent.Button
local confirm2 = script.Parent.Parent.Dark.TextButton

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


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


Thanks in advance

3 answers

Log in to vote
0
Answered by 4 years ago

in addition to what @torchmaster101 said, you also need to change the camera subject back to the player's humanoid, because by default the camera subject for a game is the player's humanoid, so add this instead of deleting the part,

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

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

0
changing camera subject prevents the part from getting destroyed when you reswitch teams AnasBahauddin1978 715 — 4y
0
Thanks guys! Just about to try this out! cricketjedi 2 — 4y
0
I think I changed it, but it still doesn't work. Maybe check this script below? cricketjedi 2 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

So, my personal advice with changing a camera type is to not just type in something like:

Camera.CameraType = "Scriptable"

But instead something like:

repeat wait()
    Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable

Camera Types are an Enumeration, so I recommend typing it like this instead of typing it as a string and in one line.

Also, line 9 of the first script confuses me. Are you trying to get the character? If you are, you can just do something like:

local character = player.Character or player.CharacterAdded:Wait()

Comment back if this doesn't fix your problem or you have any questions.

0
The repeat is important cause it helps prevent errors when switching camera types torchmaster101 92 — 4y
0
Yeah Ill try this thanks alot :) cricketjedi 2 — 4y
0
Yeah i think i am trying to get the character cricketjedi 2 — 4y
0
Oh ok, then I recommend using what I typed, but if this works for you then you can keep it :) torchmaster101 92 — 4y
0
I will try this out tomorrow cricketjedi 2 — 4y
Log in to vote
0
Answered by 4 years ago
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)

Answer this question