Team Changer Issues

Hi there. I am Crystallityy and I am a new developer at Roblox. :wave:
I am recently working on my new star wars game and I am having some issues with the team changer.

Everything works fine besides the camera and the GUI hider.
Output screenshot:

Deploy Button screenshot:

I’d like to appreciate any help regarding this issue and if you need anything else in order to help me fix this problem let me know.

Line 12; you’re trying to get the player’s character by finding the model with their username in workspace. This is wrong because players could be named the same as other models or objects in the workspace. Instead use the Player.Character property

So it would be:
Cam.CFrame = player.Character.Head.CFrame

I hope that helps

You’re trying to get the player object from workspace which isn’t going to work. You’d either have to use one of the following. Based from your code, you should probably use the first one of two below:

  1. Cam.CFrame = player.Character.PrimaryPart.CFrame
  2. Cam.Subject = player.Character

Either one should work fine.

(I didn’t mean to reply to uraveragecatboy’s post)

Not to mention that the model in the workspace which matches the player’s name is their character model not their player instance.

local button = script.Parent
local gui = game.StarterGui.MorphGuiNew
local player = game.Players.LocalPlayer
local Cam = workspace.CurrentCamera

button.MouseButton1Click:Connect(function()
	local character = player.Character
	local humanoid = character:WaitForChild("Humanoid")
	local hmr = character:WaitForChild("HumanoidRootPart")
	humanoid.Health = 0
	gui.Enabled = false
	Cam.FieldOfView = 70
	Cam.CFrame = hmr.CFrame
end)

Try this, camera is moved to the HumanoidRootPart of the player’s character.