#Camera Movement on Viewmodels

3 messages · Page 1 of 1 (latest)

lilac saffron
#


local Tool = script.Parent

local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Events = ReplicatedStorage.Events
local Models = ReplicatedStorage.Models

local AK_VM = Models.AK_VM:Clone()

local Player = game.Players.LocalPlayer
local Camera = game.Workspace.CurrentCamera
local Mouse = Player:GetMouse()

local Character = Player.Character or Player.CharacterAdded:Wait()
local Shirt = Character:WaitForChild("Shirt"):Clone()

local Equipped = false
local ADS = false
local Shooting = false


Tool.Equipped:Connect(function()
    Equipped = true
end)

Tool.Unequipped:Connect(function()
    Equipped = false
end)


Mouse.Button1Down:Connect(function()
    if Camera:FindFirstChild("AK_VM") then
        Shooting = true
    else
        return
    end
end)

Mouse.Button1Up:Connect(function()
    Shooting = true
end)


Mouse.Button2Down:Connect(function()
    ADS = true
end)

Mouse.Button2Up:Connect(function()
    ADS = false
end)

RunService.RenderStepped:Connect(function()
    if Equipped == true then

        AK_VM.Parent = Camera

        local Root = AK_VM:WaitForChild("RootPart")
        local AimPart = AK_VM:WaitFOrChild("AimPart")


        Shirt.Parent = AK_VM

        if ADS == false then 
            Root.CFrame = Camera.CFrame
        else
            AimPart.CFrame = Camera.CFrame
        end
    else
        return
    end
end)
#

thats my viewmodel script