Hi there I just need some assistance with creating this, thanks!
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.
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)
What solutions have you tried so far? Did you look for solutions on the Developer Hub? N/A
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)
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)
Omg man, I’m extremely stu—-, I forgot to make the camera type scriptable
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)
Did you put the local script under the part with the prox prompt?? Local scripts cant work in the workspace . 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)
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.
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?