Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

ThirdPerson on part touch?

I wanna make a part that, if the player touch it, the player's CameraMode will lock in ThirdPerson.

I tried this with local script, but didn't work:

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		if game.Players:FindFirstChild(hit.Parent.Name) then
			local player = game.Players:FindFirstChild(hit.Parent.Name)
			player.CameraMode = "LockThirdPerson"
		end
	end
end)

Thanking you in advance

1 answer

I assume by this you want to the camera to be locked in place without a zoom. You will want to change the ZoomDistance values.

local Players = game:GetService('Players')

local zoomDistance = 10 -- change this to how close or far you want to the camera to be

script.Parent.Touched:Connect(function(hit)
	local Player = Players:GetPlayerFromCharacter(hit.Parent)
	if Player then
		Player.CameraMode = Enum.CameraMode.Classic -- just incase you have first person lock
		Player.CameraMaxZoomDistance = zoomDistance
		Player.CameraMinZoomDistance = zoomDistance
	end -- wanna check if it's a player
end) -- onTouched

3 comments

1

Thanks, opgeeza! :)

1

No worries pal.

0

Clear explanation! Upvoted.

This discussion is preserved as it was. New answers, comments, and votes are closed.