How do I trigger a camera event when a player touches a part?

Hello, I was wondering how I could trigger a camera event when a player touches a part. Can anyone help me? Thanks for your assistance!

1 Like

Use .Touched event.
If you want move camera smoothly use tween service
Edit: .Touched event for part

So would the function be…

workspace.CutPart.Touched:Connect(function(hit)

Almost its should looks like this.
workspace.CutPart.Touched:Connect(function(hit) end)

btw you was almost right.
But remember, it should be local script.

1 Like

I called another function inside that function and the function inside that function had an error on it so how should I fix that?

Show me your script
I will try found error
Edit: oh and tell me what error

The tween in the second function has an orange line under it

workspace.CutPart.Touched:Connect(function(hit)	
	local TweenService = game:GetService("TweenService")
	
	local camera = game.Workspace.Camera
	
	local CutsceneTime = 15
	
	local tweeninfo = TweenInfo.new(CutsceneTime,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,false,0)
	
	function tween(Cut1,Cut2,Cut3,Cut4)
		camera.CameraType = Enum.CameraType.Scriptable
		camera.CFrame = Cut1.CFrame
		
		local tween = TweenService:Create(camera, tweeninfo, {CFrame = Cut4.CFrame})
		tween:Play()
		wait(CutsceneTime)
		camera.CameraType = Enum.CameraType.Custom
	
end

wait(1)

tween(workspace.Cut1,workspace.Cut2,workspace.Cut3,workspace.Cut4)

end)

Have you tried rename function? Or values. Btw what error.
Btw try do local function tween

The tw in

function tw(Cut1,Cut2,Cut3,Cut4)

only errors when the hit function is there. And no errors are in the output box

As i said, try do local function
OOOH WAIT
IK WHY (maybe)
You should check if part was touched by player
Do smth like
if hit and hit.Parent:FindFirstChild("Humanoid") then end

3 Likes

Ok I will try that but brb I got to do something rly quick.

Wait as a local function it works! Thanks!

Yay! Glad to help someone, good luck then, imma go to sleep.