I’m trying to make it so my gun system “aims in” when you hold right click. I’m attempting to do this by switching the player’s camera to the aim part attached to the tool.
It’s not working obviously, but I also need to make it so it checks if your in first person, and if you are then you can aim in.
Here is the portion of the script that aims in. It’s most likely obvious whats wrong, but I haven’t really messed with cameras much yet.
--Aiming in
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()
local camera = workspace.CurrentCamera
local tool = script.Parent
tool.Equipped:Connect(function()
Mouse.Button2Down:Connect(function()
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = tool.AimPart.CFrame
Mouse.Button2Up:Connect(function()
camera.CameraType = Enum.CameraType.Custom
end)
end)
end)
Thanks! I’m also wondering if there is away to “smoothly” switch one camera to the part, instead of it just immediately changing.