Gaabory
(Gabory)
March 13, 2024, 6:24pm
#1
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
Bikereh
(green_lady)
March 13, 2024, 6:27pm
#2
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
Gaabory
(Gabory)
March 13, 2024, 6:28pm
#3
Still oddly isn’t working. No errors or nothing either
1 Like
Bikereh
(green_lady)
March 13, 2024, 6:30pm
#4
Add
print("test")
In the trigger event to check if it is even running. Tell me what if it prints or not.
Gaabory
(Gabory)
March 13, 2024, 6:33pm
#5
It doesn’t seem to be printing.
Bikereh
(green_lady)
March 13, 2024, 6:35pm
#6
Can you show a screenshot of the properties inside your proximity prompt?
That would be the cause of the problem.
Bikereh
(green_lady)
March 13, 2024, 6:42pm
#8
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?
Gaabory
(Gabory)
March 13, 2024, 7:34pm
#9
Sorry I took so long to respond
Gaabory
(Gabory)
March 14, 2024, 7:54am
#10
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.
bytenand
(bytenand)
March 14, 2024, 8:00am
#11
Instead of using a LocalScript
, try create a regular Script
and set the RunContext
property of the script to Client
.
Gaabory
(Gabory)
March 14, 2024, 8:07am
#12
Except when I do this it sets my camera away from my player and I can’t control it.
1 Like
Gaabory
(Gabory)
March 14, 2024, 5:09pm
#13
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
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")
Gaabory
(Gabory)
March 19, 2024, 7:57am
#17
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.
Gaabory
(Gabory)
March 19, 2024, 8:52pm
#19
Yeah but FireClient can only be called from the server not clientside
Spelo1
(SpeloDev)
March 20, 2024, 7:51pm
#20
I was talking about the script that receives .OnClientEvent, not the server one that registers .Triggered