Hello, I have been working on an FPS framework but I am having some problems with it since I want it to start it’s original point and end at the opposite point/2, How do I do that?

What are you talking about? What is the “it”? Are you talking about the bullet trail or something?

Sorry, I am bad at explaining since what I want is hard to explain but here is a video that might explain it:

Code:

```
local plr = game.Players.LocalPlayer
local character = plr.Character or plr.CharacterAdded:Wait()
local humanoid = character:WaitForChild('Humanoid')
local rs = game:GetService('RunService')
local mouse = plr:GetMouse()
local cam = workspace.Camera
local viewModel = game.ReplicatedStorage.Pistol:Clone()
viewModel.Parent = cam
local cf = CFrame.new()
cf = CFrame.new(1.5,-1,1.5)
local idle = viewModel.AnimationController:LoadAnimation(viewModel.Animations.Idle)
idle:Play()
mouse.Button1Down:Connect(function()
local animation = viewModel.AnimationController:LoadAnimation(viewModel.Animations.Shoot)
animation:Play()
end)
rs.RenderStepped:Connect(function()
viewModel:SetPrimaryPartCFrame(cam.CFrame * cf)
if humanoid.MoveDirection.Magnitude > 0 then
local Y
local Time = tick()
if math.sin(Time*3)>=0 then
Y = -math.sin(Time * 3)
else
Y = math.sin(Time * 3)
end
cf = cf:Lerp(CFrame.new(1.5 *math.sin(Time*3)/3,-1+Y/3,1.5),0.1)
else
cf = cf:Lerp(CFrame.new(1.5,-1,1.5),0.1)
end
end)
```

It basically goes too far away from it’s original position (I am talking about the view model).

Theres a couple different parts to a sine wave, two of which are probably relevant to what youre doing

- Amplitude
- Frequency

Amplitude is how high a sine wave goes

High amplitude:

Low Amplitude:

Frequency is how quickly it oscillates

High frequency:

Low frequency:

A general formula you can use for sine waves is, where F is frequency and A is amplitude:

`y = sin(x * F) * A`

So in your case, to lower the amplitude you would simply substitute a low fraction or decimal in for A

`math.sin(3 * x) * 0.25`

Thank you, but how can I implement it into my system?

Like this?

```
local plr = game.Players.LocalPlayer
local character = plr.Character or plr.CharacterAdded:Wait()
local humanoid = character:WaitForChild('Humanoid')
local rs = game:GetService('RunService')
local mouse = plr:GetMouse()
local cam = workspace.Camera
local viewModel = game.ReplicatedStorage.Pistol:Clone()
viewModel.Parent = cam
local cf = CFrame.new()
cf = CFrame.new(1.5,-1,1.5)
local idle = viewModel.AnimationController:LoadAnimation(viewModel.Animations.Idle)
idle:Play()
mouse.Button1Down:Connect(function()
local animation = viewModel.AnimationController:LoadAnimation(viewModel.Animations.Shoot)
animation:Play()
end)
rs.RenderStepped:Connect(function()
viewModel:SetPrimaryPartCFrame(cam.CFrame * cf)
if humanoid.MoveDirection.Magnitude > 0 then
local Y
local Time = tick()
if math.sin(Time*3)>=0 then
Y = -math.sin(Time * 3)
else
Y = math.sin(Time * 3)
end
cf = cf:Lerp(CFrame.new(math.sin(3 * tick()) * 0.25,-1+Y/3,1.5),0.1)
else
cf = cf:Lerp(CFrame.new(1.5,-1,1.5),0.1)
end
end)
```

From what I understand about the operation of your code that implementation should work

Here is what happens when I test it:

It goes away from it’s original position

I think you just have to add 1.5 to the sin component, outside like this

`CFrame.new(1.5 + math.sin(3 * tick()) * 0.25,-1+Y/3,1.5)`

Thank you very much! It works like a charm!