Can someone explain why this isnt working?

here is my code:

local function lerpGeneral(Object,TargetSize,Time)
		
	local Ogscale = Object
	local StartTime = os.clock()
	local ScaleDiff = TargetSize-Ogscale

	local Hb Hb = RunService.Heartbeat:Connect(function()
		local ElapsedTime = os.clock() - StartTime
		local Alpha = ElapsedTime/Time

		if Alpha >= 1 then
			Hb:Disconnect()
			Object = TargetSize
		else
			local ScaleN = Ogscale + (ScaleDiff * Alpha)

			Object = ScaleN
		end
	end)
end
local WDrone = dispIece.CenterOut.WarblingDrone
WDrone:Play()
lerpGeneral(WDrone.PitchShiftSoundEffect.Octave, 2, 5)

its supposed to gradually increase the octave of the PitchShiftSoundEffect until it gets to a specified value.

I think its because the sound:play() isnt being called inside of the lerp but if it was I would need to crate a brand new lerp for each time I need something like this done. it would no longer be lerpGeneral

I should mention that the lerp works, and there are no errors. If I put a print(Object) after Object = ScaleN I can see the size gradually increasing.

If anyone could help while keeping the lerpGeneral intact that would be fantastic thanks :grin:

1 Like

Shouldnt you index the object property with a period to modify the property instead of changing rhe local variable within the functipn?

Object.PitchSoundEffect = ScaleN

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.