How would I make a the camera go on top so it shows the top of the players head when you enter a room and when you walk out it goes to normal camera style you see everyday.
Scripts, anything helps
Example: you spawn with the normal camera then when you enter a room ur camera goes top-down style
You can do this with raycasting with a white list. Here’s an example video and the script for it below. It goes in StarterCharacterScripts.
local char = script.Parent
local root = char:WaitForChild("HumanoidRootPart")
local cam = workspace.CurrentCamera
local partThatChangesStuff = workspace:WaitForChild("cameraChangerPart")
local customCameraEnabled = false;
local function enableCustomCamera()
customCameraEnabled = true
game:GetService("RunService"):BindToRenderStep("topDownCamera", 201, function()
cam.CameraType = Enum.CameraType.Scriptable
cam.CFrame = CFrame.new(root.Position + Vector3.new(0,20,0), root.Position)
end)
end
local function disableCustomCamera()
customCameraEnabled = false
cam.CameraType = Enum.CameraType.Custom
game:GetService("RunService"):UnbindFromRenderStep("topDownCamera")
end
--[[
* Checks if the player is in a custom room (standing on the custom part)
* @returns {Part|nil}
]]
local function isPlayerInCustomRoom()
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Whitelist
params.FilterDescendantsInstances = {partThatChangesStuff}
local result = workspace:Raycast(root.Position, Vector3.new(0,-10,0), params)
if (result) then
return true
end
return false
end
while wait() do
if (isPlayerInCustomRoom()) then
if (not customCameraEnabled) then
enableCustomCamera()
end
else
if (customCameraEnabled) then
disableCustomCamera()
end
end
end
First, solve the problem of detecting when a player is inside the room.
You could use a Region3 for that, or this Rotated Region3 module. Check if the player is within the room every so often. You could also detect when the player touches a part inside (to enter) and outside (to leave) the room. Or some other method. Up to you.
Second, solve the camera issue.
When the player enters the room, set their camera type: workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable. Then you can move their camera to some arbitrary CFrame.
When they leave the room, reset their CameraType back to Custom.
Note when setting the CFrame: If you have the camera be exactly perpendicular to the ground, the player’s controls will be messed up because ROBLOX won’t understand which way “forward” is. An easy fix is to make the angle something like 89 degrees, instead: