You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? I want a gun that follow the camera
-
What is the issue? I am trying to make a gun script and the gun moves with the camera but it doesn’t move correctly. https://gyazo.com/bdfb15e5adff1f0dbe5bf7da19af454e
-
What solutions have you tried so far? I tried using a bunch of different formulas but I cant get it to work.
function TweenRotation()
local Part1 = Panel.PrimaryPart
local TweenService = game:GetService("TweenService")
local x, y, z = Camera.CFrame:toEulerAnglesXYZ()
local PanelSwingInfo = TweenInfo.new(0.1) -- Let's use all defaults here
local PanelSwingTween = TweenService:Create(PanelRoot, PanelSwingInfo, {
CFrame = Camera.CFrame
})
PanelSwingTween:Play()
end
game:GetService("RunService").RenderStepped:Connect(function()
Panel:SetPrimaryPartCFrame(CFrame.new(Camera.CFrame.Position, PanelRoot.Orientation))
--PanelRoot.CFrame = Camera.CFrame:ToWorldSpace()
--PanelRoot.Position = Camera.CFrame.Position
--PanelRoot.Orientation = Camera.CFrame.LookVector
if num == 4 then
TweenRotation()
num = 0
end
num = num + 1
end)