What do you want to achieve? Keep it simple and clear!
I simply want this flashlight to have a more realistic appearance. How can I add a flashlight tool in my hand? the flashlight performs similarly to what the video did.
What is the issue? Include screenshots / videos if possible!
Actually, I don’t think there is a problem. I simply lack the necessary skills. I tried adding a flashlight tool, but I want it to be more stable because it is swaying.
What solutions have you tried so far?
Everything actually. If there is no solution, I will stick with what I now have.
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
Viewmodel Script + Sway
Put in StarterCharacterScripts
local player = game.Players.LocalPlayer
local char = player.Character
local cam = workspace.CurrentCamera
local viewmodel = game.ReplicatedStorage:WaitForChild("viewmodel"):Clone() or game.ReplicatedStorage.viewmodel:Clone() -- just incase it's already loaded
local run = game:GetService("RunService")
local CameraCF = CFrame.new()
local swayCF = CFrame.new()
local SwayX = 2
local SwayY = 2
run.RenderStepped:Connect(function()
local rotation = workspace.CurrentCamera.CFrame:toObjectSpace(CameraCF)
local x,y,z = rotation:ToOrientation()
swayCF = swayCF:Lerp(CFrame.new(math.sin(-y)*SwayX,math.sin(x)*SwayY,0), .2)
CameraCF = cam.CFrame
viewmodel:SetPrimaryPartCFrame(cam.CFrame * CFrame.new(0,-1,0)*swayCF)
end)
viewmodel.Parent = cam
viewmodel
(Sorry I wasn’t able to explain it, im not very good with explaining)