Log in to vote

How do I successfully CFrame a CameraPart in a Viewmodel to the humanoidrootpart?

Asked by 1 month ago

The extent of what I have done so far to unsuccessful results are as follows. ~~~~~~~~~~~~~~~~~ print("Script Load") -- Get the player's GUI and create a new ScreenGui as the viewmodel container local tool = game.StarterPack.M1 local playerGui = game.Players.LocalPlayer.PlayerGui local viewModelGui ="ScreenGui") viewModelGui.Name = "ViewModelGui" viewModelGui.Enabled = false viewModelGui.Parent = playerGui print("Script GUI And Viewmodel")

-- Create a new Frame as the container for the viewmodel model local viewModelFrame ="Frame") viewModelFrame.Name = "ViewModelFrame" viewModelFrame.Size =, 0, 1, 0) viewModelFrame.BackgroundTransparency = 1 viewModelFrame.Parent = viewModelGui print("Script GUI And ViewmodelFRAME")

local ViewmodelFunny = game.Workspace.VooModel ViewmodelFunny.Parent = viewModelFrame ViewmodelFunny:SetPrimaryPartCFrame(, 0, 0))) -- adjust the position of the model as needed ViewmodelFunny.PrimaryPart.Anchored = true -- lock the position of the model to prevent it from moving with the camera print("ScriptCFRAME")

local cameraPart = ViewmodelFunny.CameraBone local humanoidRootPart = ViewmodelFunny.HumanoidRootPart print("Variables :D")

local camera = game.Workspace.CurrentCamera camera.CameraSubject = cameraPart camera.CameraType = Enum.CameraType.Scriptable camera.Parent = cameraPart camera.CFrame = +, 1, -3), humanoidRootPart.Position) print("CAMERA") print(script.Parent)

script.Parent.Equipped:Connect(function(on) print("Detected") viewModelGui.Enabled = true print("true") end)

-- Hide the viewmodel when the player unequips the tool script.Parent.Unequipped:Connect(function() print("Detected But negative") viewModelGui.Enabled = false print("False") end)


Answer this question