I’m new to Roblox development so sorry if this is really obvious.
I’m trying to make it so when the player touches a part it would change the camera from 3d to 2d and back, similar to the system Super Mario Odyssey has.
So far I’ve just tried making a touch function and putting a 2d camera script into it, but that hasn’t worked. I also haven’t seen anything related to this on the DevForum.
local CameraChanger = script.Parent
local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local function PlayerTouched(Part)
player.CharacterAdded:Wait()
player.Character:WaitForChild("HumanoidRootPart")
camera.CameraSubject = player.Character.HumanoidRootPart
camera.CameraType = Enum.CameraType.Attach
camera.FieldOfView = 40
game:GetService('RunService').Stepped:Connect(function()
camera.CFrame = CFrame.new(player.Character.HumanoidRootPart.Position) * CFrame.new(0,0,30)
end)
end
CameraChanger.Touched:connect(PlayerTouched)
You don’t. You put the local script in StarterPlayerScripts, and modify the script accordingly. If you want multiple camera changing parts, use CollectionService.