Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

ThirdPerson on part touch?

Asked by 3 years ago
Edited 3 years ago

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

Log in to vote
1
Answered by
pwx 1581 Moderation Voter
3 years ago
Edited 3 years ago

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
1
Thanks, opgeeza! :) Mimas18Hun 0 — 3y
1
No worries pal. pwx 1581 — 3y
0
Clear explanation! Upvoted. Xapelize 2658 — 3y
Ad

Answer this question