Help with Proximity Prompt --> Camera Tweening

I’ve tested the code on other things before and it has worked.
But it is not working in my Proximity Prompt.

Here’s the code:

local Workspace = game:GetService("Workspace")
local CurrentCamera = Workspace.CurrentCamera
local TweenService = game:GetService("TweenService")
local Target = Workspace.REODPART
Prompt = game.Workspace.WaterCanxiety.ProximityPrompt
CurrentCamera.CameraType = Enum.CameraType.Scriptable
local TT = TweenInfo.new(1, Enum.EasingStyle.Exponential, Enum.EasingDirection.InOut, 0)
local Goal = {CFrame = Workspace.REODPART.CFrame}
local Animation = TweenService:Create(CurrentCamera, TT, Goal)

Prompt.Triggered:Connect(function()
	wait(0.1)
	Animation:Play()
end)

I am not getting any errors either.

Can you try putting prints to see if the event is actually triggering at all?

Yes, it is triggering, I think it could be to do with easing styles as those can have an effect on some pieces of code.

Put this script into “StarterPlayerScripts” as a local script:

local CurrentCamera = workspace.CurrentCamera
local TweenService = game:GetService("TweenService")

local Prompt = game.Workspace.WaterCanxiety.ProximityPrompt

CurrentCamera.CameraType = Enum.CameraType.Scriptable

local Animation = TweenService:Create(CurrentCamera, TweenInfo.new(1, Enum.EasingStyle.Exponential, Enum.EasingDirection.InOut, 0, false, 0), {["CFrame"] = workspace.REODPART.CFrame})

Prompt.Triggered:Connect(function()
   task.wait(0.1)
   Animation:Play()
end)

Yes, that worked, how would I keep the tween position at that location without it just stopping the tween?

you mean keep new cframe of camera where it got tweened?

Yes, sorry for my awful wording.

local CurrentCamera = workspace.CurrentCamera
local TweenService = game:GetService("TweenService")
local runService = game:GetService("RunService")

local Prompt = game.Workspace.WaterCanxiety.ProximityPrompt

CurrentCamera.CameraType = Enum.CameraType.Scriptable

local Animation = TweenService:Create(CurrentCamera, TweenInfo.new(1, Enum.EasingStyle.Exponential, Enum.EasingDirection.InOut, 0, false, 0), {["CFrame"] = workspace.REODPART.CFrame})

Prompt.Triggered:Connect(function(player)
	task.wait(0.1)
	Prompt.Enabled = false
	Animation:Play()
	player.Character:WaitForChild("HumanoidRootPart").Anchored = true
	Animation.Completed:Wait()
	runService:BindToRenderStep("NPCfocus", Enum.RenderPriority.Camera.Value + 1, function()
		CurrentCamera.CFrame = CFrame.new(REODPART.Position, game:GetService("Workspace").FOCUSPART.Position)
	end)
	task.wait(4)
	runService:UnbindFromRenderStep("NPCfocus")
	player.Character:WaitForChild("HumanoidRootPart").Anchored = false
end)

Okay your code gives no errors and I changed it to how I needed it,

local CurrentCamera = workspace.CurrentCamera
local TweenService = game:GetService("TweenService")
local runService = game:GetService("RunService")
local Prompt = game.Workspace.WaterCanxiety.ProximityPrompt

local Prompt = game.Workspace.WaterCanxiety.ProximityPrompt

CurrentCamera.CameraType = Enum.CameraType.Scriptable

local Animation = TweenService:Create(CurrentCamera, TweenInfo.new(1, Enum.EasingStyle.Exponential, Enum.EasingDirection.InOut, 0, false, 0), {["CFrame"] = workspace.REODPART.CFrame})

TEST = false

Prompt.Triggered:Connect(function(player)
	task.wait(0.1)
	Prompt.Enabled = false
	Animation:Play()
	player.Character:WaitForChild("HumanoidRootPart").Anchored = true
	Animation.Completed:Wait()
	runService.RenderStepped:Connect(function()
		if TEST == false then
			CurrentCamera.CFrame = CFrame.new(workspace.REODPART)
		end
	end)
	task.wait(0)
	TEST = true
	player.Character:WaitForChild("HumanoidRootPart").Anchored = false
end)

Though it still doesn’t keep the player’s camera position there it just goes back to regular player camera.

Your big problem is u removed a FOCUS part, u set new cframe to camera (CFrame.new includes two vector3) , but u didnt set the FOCUS where camera will focus

for make your script work, create new part and name it to FOCUSPART and place in front of REODPART, and after that go to script and place the comma and set FOCUSPART.POSITION, like that:

CurrentCamera.CFrame = CFrame.new(workspace.REODPART.Position, workspace.FOCUSPART.Position)

also u set task.wait() to zero, this means, renderstepped will dont run, u need to place time like that:

task.wait(4)

full script to copy:

local CurrentCamera = workspace.CurrentCamera
local TweenService = game:GetService("TweenService")
local runService = game:GetService("RunService")

local Prompt = game.Workspace.WaterCanxiety.ProximityPrompt

CurrentCamera.CameraType = Enum.CameraType.Scriptable

local Animation = TweenService:Create(CurrentCamera, TweenInfo.new(1, Enum.EasingStyle.Exponential, Enum.EasingDirection.InOut, 0, false, 0), {["CFrame"] = workspace.REODPART.CFrame})

TEST = false

Prompt.Triggered:Connect(function(player)
	task.wait(0.1)
	Prompt.Enabled = false
	Animation:Play()
	player.Character:WaitForChild("HumanoidRootPart").Anchored = true
	Animation.Completed:Wait()
	runService:BindToRenderStep("NPCfocus", Enum.RenderPriority.Camera.Value + 1, function()
		CurrentCamera.CFrame = CFrame.new(REODPART.Position, game:GetService("Workspace").FOCUSPART.Position)
	end)
	task.wait(4)
	runService:UnbindFromRenderStep("NPCfocus")
	player.Character:WaitForChild("HumanoidRootPart").Anchored = false
end)

gif3robloxstudio

1 Like

Okay great, thank you that works, sorry for taking so long to understand!

1 Like