I’m trying to achieve a working weapon inspect viewport. My issues are the viewport has terrible positioning and just doesn’t even want to work. So far I tried setting the model’s cframe to the mouse but still isn’t working. Any idea why?
local mouse = game:GetService("Players").LocalPlayer:GetMouse()
local tweenService = game:GetService("TweenService")
local userinputservice = game:GetService("UserInputService")
local x = false
userinputservice.InputBegan:Connect(function(input, gpe)
if gpe then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 then
x = true
end
end)
userinputservice.InputEnded:Connect(function(input, gpe)
if gpe then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 then
x = false
end
end)
game["Run Service"].RenderStepped:Connect(function()
if x == true then
script.Parent.ViewportFrame["Raging bull gun"].CFrame.Rotation = CFrame.new(-mouse.Hit.Position.X, mouse.Hit.Position.Y, mouse.Hit.Position.Z)
end
end)