Proxmity Prompt Activates Camera Tween to Part

Hi there I just need some assistance with creating this, thanks!

  1. What do you want to achieve?
    When the Proximity Prompt is fired, I need it to tween to the position and orientation of a part that is located within the Rig’s Model.

    I also have a 2nd script that if for the dialogue that also relies on the same proximity prompt which I want to work in as well.

  2. What is the issue? Include screenshots / videos if possible!
    I don’t really know how I would go about this.
    Here is a model file of what I’m talking about. There will be many of these NPCs so if possible, I would like to keep it in the Rig.
    JimmyCamera.rbxm (29.5 KB)

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    N/A

Thank you!

The idea is to manipulate the CurrentCamera of the local player and change the CFrame of the camera to the part (Code should be in a local script)

local tweentopart = -- Put the part in the rig here
local player = game.Players.LocalPlayer
local cam = workspace.CurrentCamera
local TS = game:GetService('TweenService')
local TI = TweenInfo.new(3--[[Time]], Enum.EasingStyle.Linear)
local ProxPrompt = --Your prompt here

ProxPrompt.Triggered:Connect(function()
   local tween = TS:Create(cam,TI,{CFrame = CFrame.new(part.Position,player.Character.PrimaryPart.Position)})
   tween: Play()
end)

Thank you, ill test this out and come back to you.

Hi, I’ve put this in and configured it to how I want it to work.

Interaction Camera is the Part in the Rig’s Model that would change the local camera to it’s position.

The Proximity prompt is just the prompt in the rig.

It hasn’t worked which was odd, I’ve tried prints and whatnot didn’t show up, no errors whatsoever in the console. Is there something I’ve done wrong?

local tweentopart = script.Parent.InteractionCamera
	local player = game.Players.LocalPlayer
local cam = workspace.CurrentCamera
local TS = game:GetService('TweenService')
local TI = TweenInfo.new(3--[[Time]], Enum.EasingStyle.Linear)
local ProxPrompt = script.Parent.ProximityPrompt

	ProxPrompt.Triggered:Connect(function()
		local tween = TS:Create(cam,TI,{CFrame = CFrame.new(part.Position,player.Character.PrimaryPart.Position)})
	tween: Play()
	end)

Can you try the triggered event in the server and fire a remote event to the client?

It won’t work which is frustrating, is there anything else we could try?

Omg man, I’m extremely stu—-, I forgot to make the camera type scriptable :man_facepalming:


local tweentopart = script.Parent.InteractionCamera
	local player = game.Players.LocalPlayer
local cam = workspace.CurrentCamera
local TS = game:GetService('TweenService')
local TI = TweenInfo.new(3--[[Time]], Enum.EasingStyle.Linear)
local ProxPrompt = script.Parent.ProximityPrompt

	ProxPrompt.Triggered:Connect(function()
		cam.CameraType = Enum.CameraType.Scriptable
local tween = TS:Create(cam,TI,{CFrame = CFrame.new(part.Position,player.Character.PrimaryPart.Position)})
	tween: Play()
	end)

1 Like

Hmm, this is what I’ve run into, nothing in the output.

Did you put the local script under the part with the prox prompt?? Local scripts cant work in the workspace :skull:. Put the prompt in the interaction camera for simplicity and this local script in starterplayerscripts

local tweentopart = workspace.Rig.InteractionCamera
	local player = game.Players.LocalPlayer
local cam = workspace.CurrentCamera
local TS = game:GetService('TweenService')
local TI = TweenInfo.new(3--[[Time]], Enum.EasingStyle.Linear)
local ProxPrompt = workspace.Rig.InteractionCamera.ProximityPrompt

	ProxPrompt.Triggered:Connect(function()
		cam.CameraType = Enum.CameraType.Scriptable
local tween = TS:Create(cam,TI,{CFrame = CFrame.new(part.Position,player.Character.PrimaryPart.Position)})
	tween: Play()
	end)

Oh mb, thanks. I appreciate it

Here’s what I’ve got. I’m very thankful for directing me in the right place, Interaction Camera can’t be found however, as you can see below, I’ve tried to find first child as I was just experimenting.

Here’s what was in the output:

local tweentopart = game.Workspace.Jimmy:FindFirstChild("InteractionCamera")
local player = game.Players.LocalPlayer
local cam = game.Workspace.CurrentCamera
local TS = game:GetService('TweenService')
local TI = TweenInfo.new(3--[[Time]], Enum.EasingStyle.Linear)
local ProxPrompt = game.Workspace.Jimmy:FindFirstChild("InteractionCamera").ProximityPrompt

ProxPrompt.Triggered:Connect(function()
	cam.CameraType = Enum.CameraType.Scriptable
	local tween = TS:Create(cam,TI,{CFrame = CFrame.new(part.Position,player.Character.PrimaryPart.Position)})
	tween: Play()
end)

The problem is that this ‘Jimmy’ doesn’t exist at that specific point of time. Did you try waiting for jimmy to load in with :WaitForChild() or double-checking the name?

Hmm, I definitely know that “Jimmy” exists, the name has no spaces or anything, I’ll try :WaitForChild()