Basically what the title says. What I trying to say is how would I make a part turn the camera from Zoom to Invisicam?
Please can you explain a bit more clearly what you’re trying to achieve. For example, I have no idea what “invisicam” is, and what do you mean by “part turn camera”?
If you don’t know how to explain it in words, possibly try providing an example for what it is you are trying to achieve, so that I can help you figure it out.
The way to make your camera “Invisicam” is by heading over the LocalPlayer’s properties and finding a property named “DevCameraOcclusionMode”
The API Documentation states that there are two modes, “Zoom” and “Invisicam”, Since you want invisicam, you’d set the DevCameraOcclusionMode to “Invisicam”
game:GetService("Players").LocalPlayer.DevCameraOcclusionMode = "Invisicam"
what is what im talking about
but what im trying to achieve is when a player touches a part it will turn the camera to invisicam until the player is no longer touching it
so how would i make a script for that?
I believe to replicate this effect you could use Rays.
You could go about doing this by first, getting the camera’s CFrame, and then shooting a beam to the Player’s position. If there is anything in the way, however, then you’ll make the part’s Transparency, for example, 0.5.
You’ll also need to make a table to store that part in, as to add it to the rays ignore list until the player is no longer in contact with the part, where it’ll be removed.
You’ll have to set this up client-sided, as the camera can only be accessed from there. However, you’ll also need to use a RemoteEvent to send the camera’s position to the server, where it can make a ray, and then it’ll send a request to make that part transparent.
With all of this in mind, the script would look something like this.
-- L O C A L S C R I P T
local Camera = workspace.CurrentCamera
local Remote = REMOTE_HERE
LOOP_WITH_RUN_SERVICE_HERE
local pos = Camera.CFrame
Remote:FireServer(pos)
END_LOOP
Remote.OnClientEvent:Connect(function(part)
part.Transparency = 0.5
end)
-- S E R V E R S C R I P T
local Remote = REMOTE_HERE
Remote.OnServerEvent:Connect(function(player, pos)
local Ray = RAY_CREATION_HERE
GET_PART_FROM_RAY_HERE
if PART_HERE then
Remote:FireClient(player, PART_HERE)
end
end)```
sorry but I dont know what “rays” are. I’m new to coding lua(super beginner level) and I dont really understand what you just typed. Sorry for the inconvenience but is there a .rbxl file I could look at and try and follow what your saying. I mean I understand parts of what u typed because of the comments but…
Rays in math I believe are lines which infinitely stretch in 1 direction and yet are finite in another (so they’re basically a line). In roblox, their size is changeable. Anyway, rays are things we use in roblox to detect parts with more precision. For example, many swords use rays to detect hits instead of using .Touched due to it’s lack of accuracy.
If you’d like, you can read up on Rays at this link right here, which will tell you how to make a laser gun with the use of raycasting. The wiki page for raycasting is also right here. However, if those two sources are not enough, there is also this video which helped me out a lot.
so would I make it a script like the one u made or would I would I have to go to properties and change it to Invisicam?
Are you trying to make the camera change while they, for example, stand on a part, or when their camera is blocked by a part?
im trying to make it where when they stand on a part it changes the camera from zoom to invisicam
Here’s how I would do it
- Constantly raycast downwards to check if the part you’re standing on is the part you’re looking for. The best way to do this is hold all of the parts inside a whitelist folder and use workspace:FindPartOnRay. I’d use FindPartOnRayWithWhitelist, but in case you have some parts on top of those whitelisted parts, you don’t want to accidentally ignore them.
- If we find the part we’re looking for, set the DevCameraOcclusionMode to Invisicam. If not, set it to default.
The code would look something like this:
local player = game.Players.LocalPlayer
local character = player.Character
local whitelistedFolder = workspace.WhitelistedFolder -- folder that holds all the parts where if you stand on them, it toggles the invisicam
game:GetService"RunService":BindToRenderStep("CheckPartsForInvisicam", Enum.RenderPriority.Camera.Value - 1, function()
local ray = Ray.new(character.Head.Position, Vector3.new(0, -10, 0))
local hitPart = workspace:FindPartOnRay(ray, character)
if hitPart and hitPart.Parent == whitelistedFolder then
player.DevCameraOcclusionMode = Enum.DevCameraOcclusionMode.Invisicam
else
player.DevCameraOcclusionMode = Enum.DevCameraOcclusionMode.Zoom
end
end)
Let me know if this works.
sorry to bother you with this information but, ive turned away from having a player touch an object in order to turn it to invisicam. So instead what ive done is the whole game is gonna have invisicam on.
which brought up a new problem in this thread
what im tryna figure is add a script(if there is) to the camera script that I already have.