Camera works fine in studio, but not In the client

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Make a realistic first person script with AI

  2. What is the issue? Include screenshots / videos if possible!
    The camera works fine in roblox studio but gets stuck in the place you died on the roblox desktop app

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have found no solutions.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

The output says: “HumanoidRootPart is not a valid member of workspace.Username Here”

local player = game:GetService("Players").LocalPlayer
local character = player.Character

local function toggleCharacterVisibility()
	if player.CameraMode == Enum.CameraMode.LockFirstPerson then
		character.HumanoidRootPart.Transparency = 0
	else
		character.HumanoidRootPart.Transparency = 1
	end
end

player:GetPropertyChangedSignal("CameraMode"):Connect(toggleCharacterVisibility)

I generated this Localscript with the Assistant by the way

and yes, I did try it without a modified client.

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

I changed where the character was being defined to always get the newest character. Also, I made a check to determine if there was a HumanoidRootPart in the character to fix the error you outlined above. Let me know if it still does not work properly! :blush:

local player = game:GetService("Players").LocalPlayer

local function toggleCharacterVisibility()
        local character = player.Character -- get the newest character

        if not character or not character:FindFirstChild("HumanoidRootPart") then
                return -- if no humanoidrootpart then dont continue
        end

	if player.CameraMode == Enum.CameraMode.LockFirstPerson then
		character.HumanoidRootPart.Transparency = 0
	else
		character.HumanoidRootPart.Transparency = 1
	end
end

player:GetPropertyChangedSignal("CameraMode"):Connect(toggleCharacterVisibility)
1 Like

I will try, i will update you soon!

I tried, It did not do anything

1 Like

Okay, if the problem is not solved by the time I can test the script myself and fix it (around 5 hours from now), I’ll get back to you with a working version and a description of what I changed. Thanks for your patience.

1 Like

Alright. I gotta go in 2 hours so I will probably check back tomorrow.

1 Like

actually, I will make a script inside startercharacter script that prints out all the players children to see why it says it has no HumanoidRootPart.

Edit: The print didn’t say anything either.

Edit 2: I found out that if you reset your character while your camera is broken, It fixes itself. I’m trying to implement a fix.

Edit 3: I successfully implemented a fix by making the death animation script that probably caused the issue to Set the players health to 0 right when they respawn so the camera fixes itself.

Edit 4: nevermind. it broke again :frowning:

Edit 5: I identified the flaw. I had just put a ragdoll death script that interfered with the death animation. I now fixed the issue. I am sorry for any inconvenience caused by this issue.