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

Function to check if a player has zoomed in?

Asked by
Cr0ws 20
10 years ago

**Do I have to use coordinate frame of some sort? **

plr = game.Players.LocalPlayer
ZoomedIn = false

--{{Some Camera Function}}
ZoomedIn = true
print(plr.Name.." has zoomed in.")






--{{end}}


1 answer

Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 years ago

You can get the distance between the Camera and the Character's Head, which should be 0 if they are fully zoomed in:

plr = game.Players.LocalPlayer
ZoomedIn = false
local camera = workspace.CurrentCamera

camera.Changed:connect(function() --probably a better event to connect to than this, but this should work.
    if (camera.CoordinateFrame.p - plr.Character.Head.CFrame.p).magnitude <= .5 then
        ZoomedIn = true
        print(plr.Name.." has zoomed in.")
    else
        ZoomedIn = false
        print(plr.Name .. " is not zoomed in.")
    end
end
Ad

Answer this question