How can I make math.sin() slower?

hi, I am using sine waves to create a bobbing effect but this happens;


function guns:Update(dt)
	self.bobbing =*100),math.sin(tick()*100),0)
self.Character.Torso["Right Shoulder"].C0 = Variables.RightC0 *

when I call it;

self.Connect = game:GetService("RunService").RenderStepped:Connect(function(dt)

How can I make it slower? :frowning:

1 Like

Maybe try changing the ‘100’ to something else.

hm, no I think it’s because the loop speed, is there any other way?

The value passed into the sine function is the only thing that should be affecting the speed of the oscillation, so no.

I wouldn’t mess with the RunService loop, anyway. Just try using a number lower than 100 in the sine function and see if that works.

1 Like
Code format sent

local playing, completed = Enum.PlaybackState.Playing, Enum.PlaybackState.Completed
local style, dir = Enum.EasingStyle.Sine, Enum.EasingDirection.InOut

local sin = script:WaitForChild(“Sine”) --remember, the NumberValue; it will act as the “time” for our curve
local isSprinting = char.Sprint:WaitForChild(“IsSprinting”) --aah, finally it came in use

local dur, durSprint = 0.675, 0.5 --tween duration while walking & sprint time, respectively

–the tweens for walking and sprinting (I made them reverse, but running only once)
local ti, tiSprint =, style, dir, 0, true),, style, dir, 0, true)
local oneTween, oneSprintTween = ts:Create(sin, ti, {Value = 1}), ts:Create(sin, tiSprint, {Value = 1})

–offset = camera offset; maxRandomBounds = for clamping the Perlin Noise value for point0
local offset, maxRandomBounds = 0.25, 0.5

–point0 and point2 are on the right and left side, respectively
local point0, point2 =, 0, 0),, 0, 0)

–remember, point1 is in the middle; we’ll be using Perlin Noise for the X position
local point1 =, -offset, 0)

local ti2 = / 2, style, dir)

–tween back to the origin
local tweenBack = ts:Create(hum, ti2, {CameraOffset =, 0, 0)})

–tween to point0 so it can bob back and forth
local begTween = ts:Create(hum, ti2, {CameraOffset = point0}) --no, I’m not making the tween beg!

–this will be for our Perlin Noise, the higher the inc, the more random
local counter, counterInc = 1, 0.1

–this will be true once begTween starts playing (to make it not play again)
local running = false

This text will be hidden

When trying to show code on the devloper forum, please use code blocks. If you don’t know how to do code blocks there is a tutorial here

Basically when replying just click the symbol up the top, (</>) and it should work.

You can just try lerping it like this

local alpha = 0.1
function guns:Update(dt)
	self.bobbing =*100),math.sin(tick()*100),0)
    self.Character.Torso["Right Shoulder"].C0 =  
       self.Character.Torso["RightShoulder"].C0:Lerp(Variables.RightC0 *, alpha)


also for anyone wondering why not decrease ‘100’ that’s because 100 determines the amplitude of the wave not the speed at which the values change

also OP the larger the alpha value the more incremental the change would be, lerping doesn’t necessarily make it slower but it just moves to the target value in specified increments determined by the alpha

1 Like