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

How to stop zooming out from the character when tool is being hold by him ?

Asked by
Bulvyte 388 Moderation Voter
7 years ago
Edited 7 years ago

How do i do it ? i have no idea if i do the minzoomdistance in player and max it will make it very buggy so what's the other way ?

Tool = script.Parent
player = game.Players.LocalPlayer
Char = player.Character

Max = player.CameraMaxZoomDistance

Tool.Equipped:connect(function()
    player.CameraMaxZoomDistance = 0.5
end)

Tool.Unequipped:connect(function()
    player.CameraMaxZoomDistance = Max
end)


0
I'm using it currently for a project and it's not buggy for me. Show us the script that uses Max/Min Camera Zoom and we can help you fix it. I think I might already know the problem, but I need to see the script to be sure. User#11440 120 — 7y
0
there Bulvyte 388 — 7y

1 answer

Log in to vote
1
Answered by 7 years ago
Edited 7 years ago

Well,

Because you didn't explain what "buggy" means, I'm going to have to assume.

Testing this does exactly what you would expect it to do.

I'm assuming you want it to zoom the camera back out again once you Unequipped the tool. Luckily for you, there's a CameraMinZoomDistance!

Tool = script.Parent
player = game.Players.LocalPlayer
Char = player.Character
Max = player.CameraMaxZoomDistance

Tool.Equipped:connect(function()
    player.CameraMaxZoomDistance = 0.5
end)

Tool.Unequipped:connect(function()
    player.CameraMaxZoomDistance = Max
    player.CameraMinZoomDistance = 12
    player.CameraMinZoomDistance = 0.5
end)

Obviously this can be adjusted to not allow the player to zoom in or out as well by Setting camera max and min distance to the same.

Extra info,

You can get where the What the current camera zoom is by finding the magnitude of the Camera Position and the Local Player's Head position, like so,

-- Local Script
local plr = game.Players.LocalPlayer
local char = plr.CharacterAdded:wait()
local Head = char:WaitForChild("Head")
local cam = workspace.CurrentCamera

while wait() do
    print((cam.CFrame.p-Head.Position).Magnitude)-- Prints current Camera Zoom Distance
end

Good Luck!

I might have misunderstood the question, idk.
0
finally, im learning something. Bulvyte 388 — 7y
0
<3 User#11440 120 — 7y
Ad

Answer this question