–{ Introduction }–
Hello there Fellow Developers!
–{ Notes / Sorry }–
(EDIT: I know that i’ve been frequently making alot of Topics in DevForum, If i could just delete those. I would, I’m very sorry about that. )
–{ Something im having trouble with }–
I’m here again because i need help connecting the gun to the Viewmodel without using the Hotbar
, This has been hard for me. Since class is coming soon. I do not have time to finish this, It would take me a Year to finish with class.
–{ The Code given by @BriefYayyayyay for the viewmodel }–
local viewmodel = game.ReplicatedStorage.Viewmodel:Clone() -- You will need your viewmodel here
viewmodel.Parent = workspace
local lastCamCFrame = CFrame.new()
local swayCFrame = CFrame.new()
workspace.CurrentCamera:GetPropertyChangedSignal("CFrame"):Connect(function()
local rotation = workspace.CurrentCamera.CFrame:ToObjectSpace(lastCamCFrame)
local X, Y, Z = rotation:ToOrientation()
swayCFrame = swayCFrame:Lerp(CFrame.Angles(math.sin(X) * 0.7, math.sin(Y) * 0.7, 0), 0.1)
lastCamCFrame = workspace.CurrentCamera.CFrame
viewmodel.CamPart.CFrame = workspace.CurrentCamera.CFrame * swayCFrame
end)
robloxapp-20220911-1527167.wmv (1.4 MB) here’s the Video of it working.
–{ Images }–
1st Image:
–{ Final Notes }–
Sorry for the Topic Spamming, If i could delete it. I would