Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My Change CameraMode Script Nonfunctioning?

I have, in StarterGui, a ScreenGui then a frame, in the frame is a textbutton, and in the button there's a localscript that should change the camera lock mode to the opposite (eg, if in 3rd person it changes to first, and if in 1st person it changes to third)

I know that this can be changed as easy as scrolling your mouse, but I want a feature in my game more or less to just fill a space so my OCD doesn't drive me crazy. Here is the content in the localscript.

--script by OpticUniversse, with help by _____ (insert your name here for credit)

if LocalPlayer.CameraMode = Enum.Cameramode.ThirdPerson then
	game.Players.LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
else if LocalPlayer.CameraMode = Enum.Cameramode.FirstPerson then
	game.Players.LocalPlayer.CameraMode = Enum.CameraMode.LockThirdPerson

end

However, it doesn't seem to work. I'm not very good at this, so if anyone wants to give me some pointers on how to fix it, I'd appreciate it very much. Thanks!

2 comments

0

Can you check if this code is ran by adding prints into each logic choice

0

Use leif not else if.

1 answer

Try this.

--script by OpticUniversse, with help by Anthony9960 (insert your name here for credit)
-- local LocalPlayer = game.Players.LocalPlayer -- Just in case if you didn't have LocalPlayer Defined

if LocalPlayer.CameraMode == Enum.CameraMode.Classic then
    game.Players.LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
elseif LocalPlayer.CameraMode == Enum.CameraMode.LockFirstPerson then
    game.Players.LocalPlayer.CameraMode = Enum.CameraMode.Classic
end

2 comments

0

Thanks, but I inserted this and it doesn't work. Should I be using a localscript or script? Thanks.

0

you should be using a local script to access the local player

This discussion is preserved as it was. New answers, comments, and votes are closed.