I am triggering a ProximityPrompt that will Tween the camera to a brick position. Unfortunately, I get no output nor do I get anything out of it. I’ve put the script in various places (LocalScript, by the way) and I still can’t seem to get anything out of it.
I do have a bobble script, maybe that could be why it is not allowing my script to run? I will test it in a bit. But my script still doesn’t print anything so I am unsure why.
Script:
local Prox = script.Parent
local Cam = game.Workspace.CurrentCamera
local TweenService = game:GetService("TweenService")
Prox.Triggered:Connect(function(plr)
if plr then
print("Triggered")
TweenService:Create(Cam, TweenInfo.new(2, Enum.EasingStyle.Cubic,Enum.EasingDirection.Out, 0, false, 0.2),{CFrame = CFrame.new(Cam.CFrame.p)}):Play()
end
end)
local Cam = game.Workspace.CurrentCamera
local TweenService = game:GetService("TweenService")
local RemoteEvent = game:GetService("ReplicatedStorage").RemoteEvent -- wherever u put a remote event
RemoteEvent.OnClientEvent:Connect(function()
TweenService:Create(Cam, TweenInfo.new(2, Enum.EasingStyle.Cubic,Enum.EasingDirection.Out, 0, false, 0.2),{CFrame = CFrame.new(Cam.CFrame.p)}):Play()
end)
Script inside ServerScriptService:
local RemoteEvent = game:GetService("ReplicatedStorage").RemoteEvent -- remote event u made
RemoteEvent:FireClient(plr you want to tween cam)
if u want to use proximity just forget that normal script and put this inside proximity prompt
local RemoteEvent = game:GetService("ReplicatedStorage").RemoteEvent -- remote event u made
local Prox = script.Parent
Prox.Triggered:Connect(function(PlrTriggering)
RemoteEvent:FireClient(PlrTriggering)
end)
Because I get the feeling you’ve placed a LocalScript in Workspace.
That just won’t work. For optimal location(s), place it in StarterPlayerScripts or StarterGUI.
I got it working last night. I had to look up some stuff to get it working. But I still have an issue.
(Just in case you need the script again)
local Prox = game.Workspace.R6.Chat.ProximityPrompt
local Cam = game.Workspace.CurrentCamera
local TweenService = game:GetService("TweenService")
local NPC = game.Workspace.R6
-- This script is located inside StarterPlayerScripts.
local function onProximityPromptTriggered()
print("Triggered")
TweenService:Create(Cam, TweenInfo.new(2, Enum.EasingStyle.Cubic,Enum.EasingDirection.Out, 0, false, 0.2),{CFrame = CFrame.new(NPC.Camera.CFrame)}):Play() -- Give error saying "Vector3 expected".
game.StarterPlayer.StarterCharacterScripts.CamBob.Enabled = false -- Disable it so it doesn't interfere with the tween
wait(1.5)
while true do --Not sure how else to move Camera to desired rotation and position. This breaks
wait()
Cam.CFrame = NPC.Camera.CFrame -- Move Camera to NPC chat view
end
end
Prox.Triggered:Connect(onProximityPromptTriggered)
The position of the camera goes to the brick, but it doesn’t rotate to where I need it to, adding onto that I’m not sure how to keep it there once I finish. I tried to get it to stay with a while loop, but brings it back to player view, just the rotation is wacky.
Most of the issues I quoted inside my script. My main goal is to keep it there so I can add movement (Like breathing) to it while chatting with the NPC.
First of all, if you want to use {CFrame = } you don’t need to do CFrame.new, just do:
{CFrame = NPC.Camera.CFrame}
CFrame.new() requires you to provide the part’s vector3 position, AKA your (x, y, z) values in the part’s CFrame Position property. By right, after playing the tween, the camera should stay there unless you either 1. Have an error, or 2. You have additional code that overwrites your intended goal. In this case, you have an error which is your CFrame value.
You can remove the while loop and test out the code with what I’ve given and it should be at the position of the NPC CFrame. If the camera is looking at the direction you don’t want to, I suggest using the lookAt parameter which you can take a look at in the Documentation. (I haven’t tried this with just {CFrame = } alone)
local Prox = script.Parent
local CameraManipulatorRemote = game.ReplicatedStorage.YourGoodRemoteNameHere
Prox.Triggered:Connect(function(player)
if player then
CameraManipulatorRemote:FireClient(player)
end
end)
Client |
local CameraManipulatorRemote = game.ReplicatedStorage.YourGoodRemoteNameHere
local Camera = workspace.CurrentCamera
local TweenService = game:GetService("TweenService")
CameraManipulatorRemote.OnClientEvent :Connect(function()
TweenService:Create(Cam, TweenInfo.new(2, Enum.EasingStyle.Cubic,Enum.EasingDirection.Out, 0, false, 0.2),{CFrame = CFrame.new(Cam.CFrame.p)}):Play()
end)