Hey everyone, Dose anyone know why this script doesn’t parent the camera back to the player?
local openGunShopButton = gui.Parent:WaitForChild("OPen")
openGunShopButton.MouseButton1Click:Connect(function()
local defaultPart = gunFolder:FindFirstChild("DefaultCamera")
if defaultPart then
if camera.CameraSubject == defaultPart then
-- Reset the camera back to the player
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
camera.CameraType = Enum.CameraType.Custom
camera.CameraSubject = humanoid
mouseMovementEnabled = true
else
-- Parent the camera to DefaultCamera
camera.CameraType = Enum.CameraType.Scriptable
camera.CameraSubject = defaultPart
camera.CFrame = defaultPart.CFrame
mouseMovementEnabled = false
end
end
end)
I dont think you ever added
camera.Parent = character
Also camera.CameraSubject I don’t think is humanoid try
character.Head
Im having a hard time implementing it do you mind doing it?
openGunShopButton.MouseButton1Click:Connect(function()
local defaultPart = gunFolder:FindFirstChild("DefaultCamera")
if defaultPart then
if camera.CameraSubject == defaultPart then
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
camera.CameraType = Enum.CameraType.Custom
camera.CameraSubject = humanoid
mouseMovementEnabled = true
else
camera.CameraType = Enum.CameraType.Scriptable
camera.CameraSubject = defaultPart
camera.CFrame = defaultPart.CFrame
mouseMovementEnabled = false
end
end
end)
first clarify. do you want the camera to just go back to normal controls or do you want it parented to the character as well.
But I think,
openGunShopButton.MouseButton1Click:Connect(function()
local defaultPart = gunFolder:FindFirstChild("DefaultCamera")
if defaultPart then
if camera.CameraSubject == defaultPart then
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
camera.CameraType = Enum.CameraType.Custom
camera.CameraSubject = character.Head
mouseMovementEnabled = true
else
camera.CameraType = Enum.CameraType.Scriptable
camera.CameraSubject = defaultPart
camera.CFrame = defaultPart.CFrame
mouseMovementEnabled = false
end
end