- What do you want to achieve?
Well, I need help with something, I’m trying to make a tool go into first person when you equip it, I thought about using remote events, but I’m honestly stuck, I need help.
Well, I need help with something, I’m trying to make a tool go into first person when you equip it, I thought about using remote events, but I’m honestly stuck, I need help.
Try this:
Directly inside of your tool create a LocalScript and try the following:
script.Parent.Equipped:Connect(function()
game.Players.LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
end)
script.Parent.Unequipped:Connect(function()
game.Players.LocalPlayer.CameraMode = Enum.CameraMode.Classic
game.Players.LocalPlayer.CameraMinZoomDistance = 10 -- Kick the player out of first person
wait()
game.Players.LocalPlayer.CameraMinZoomDistance = 0.5 -- Allow them back into first person if they want
end)
Nice script, here’s how I’d write it.
local tool = script.Parent
local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local head = character:WaitForChild("Head")
local camera = workspace.CurrentCamera
tool.Equipped:Connect(function()
local distance = (head.Position - camera.CFrame.Position).Magnitude
player.CameraMode = Enum.CameraMode.LockFirstPerson
local connection do
connection = tool.Unequipped:Connect(function()
player.CameraMode = Enum.CameraMode.Classic
player.CameraMinZoomDistance = distance
player.CameraMinZoomDistance = 0.5
connection:Disconnect()
end)
end
end)
When the tool is equipped the camera’s current zoom distance is saved. When the tool is eventually unequipped, the camera’s zoom goes back to its previous position.
Thank you guys,it worked perfectly.