Hi there. I am Crystallityy and I am a new developer at Roblox.
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:
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
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:
Cam.CFrame = player.Character.PrimaryPart.CFrame
Cam.Subject = player.Character
Either one should work fine.
(I didn’t mean to reply to uraveragecatboy’s post)
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.