Camera change on ProximityPrompt trigger

image
Haven’t used the Camera in studio that much before and I’m a bit confused as to how it works. All I’m trying to do is to make the player’s camera go to a part’s Cframe when it is triggered but it’s not working.

Not getting any errors either and this seems to be the most viable way for me to do this. Any help?

1 Like

Instead of doing camera = closestcamera.CFrame try camera.CFrame = closestcamera.CFrame

When changing the camera type I would use

repeat camera.CameraType = Enum.CameraType.Scriptable
	wait()
until  camera.CameraType == Enum.CameraType.Scriptable

because sometimes the camera does not change on the first try.

1 Like

Still oddly isn’t working. No errors or nothing either

1 Like

Add

print("test") 

In the trigger event to check if it is even running. Tell me what if it prints or not.

It doesn’t seem to be printing.

Can you show a screenshot of the properties inside your proximity prompt?
That would be the cause of the problem.

image

can you show a video of you using the prompt? if it would take too long to send a video then can you send a picture of you standing next to the prompt so that it would show up in game?


Sorry I took so long to respond

If I put the code into a local script nothing happens, if the code is in a server script then the code does print into the output but still nothing happens.

Instead of using a LocalScript, try create a regular Script and set the RunContext property of the script to Client.

Except when I do this it sets my camera away from my player and I can’t control it.

1 Like

Can anyone else suggest a solution?

Maybe bounce the camera code from Server To Client?

Start off by inserting a RemoteEvent into ReplicatedStorage and naming it “ClosetCamera”

Server

local prompt = script.Parent.ProximityPrompt 
local closetcamera = workspace.ClosetCamera
prompt.Triggered:Connect(function(player) 
	game.ReplicatedStorage:WaitForChild("ClosetCamera"):FireClient(player,closetcamera)
end)

Client

local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
game.ReplicatedStorage:WaitForChild("ClosetCamera").OnClientEvent:Connect(function(closetcamera)
	camera.CFrame=closetcamera.CFrame
	camera.CameraSubject=closetcamera
end)

Let me know if this helps!

1 Like

Still nothing happening.

Can you add a warning or print of something to check if the event is firing to the client?

Just add something like below to the part where it should change the camera

print("Event is fired")
local camera = workspace.CurrentCamera
local entercamera = workspace.EnterCamera

camera.CameraType = Enum.CameraType.Scriptable

game.ReplicatedStorage:WaitForChild("ClosetCamera").OnClientEvent:Connect(function(entercamera)
	camera.CFrame = entercamera.CFrame
	print("Event fired")
	camera.CameraSubject = entercamera
end)

With this code nothing prints.

  1. Local Scripts don’t run in Workspace, so use RunContext in Script with value of “Client” like suggested earlier
  2. Change CameraType in the event itself, so the player doesn’t start with the Scriptable type from the start

Yeah but FireClient can only be called from the server not clientside

I was talking about the script that receives .OnClientEvent, not the server one that registers .Triggered