How can I make a delay for when I move my camera?

I have a local script:

local gg = workspace.gg
local camera = workspace.CurrentCamera
part.Anchored = true
part.CanCollide = false

camera.Changed:connect(function()
gg.CFrame=camera.CFrame*CFrame.new(0,-0.43,-1.5)

end)

In which I have an object attached to the camera so it makes a custom holding system. My problem is whenever I move the camera the object goes to the exact place everytime, I want there to be a delay. For example if I quickly turn right I want the object to catch up to the exact place like a half a second later. How could I do this?

I’m no scripter, but I beleive if you put a wait function in there then it should make there be a delay.

local gg = workspace.gg
local camera = workspace.CurrentCamera
part.Anchored = true
part.CanCollide = false

camera.Changed:connect(function()
wait (however long you want it to wait)
gg.CFrame=camera.CFrame*CFrame.new(0,-0.43,-1.5)

end)

I beleive there might work? Like I siad I’m no scripter and I’m not sure if this would help or not, I’m pretty sure the wait function would be the way to go but where you put it and what not I’m not exactly sure.

No that won’t work because that would just make the part move very unsmooth.

If you’d like to have a delay I’d recommend adding a wait like guy above said or TweenService:Create to move part to new position smoothly. This will automatically be slower due to a object animation. I understood you problem like that if I am wrong let me know. I hope this helps. :herb:

CFrame probably isn’t the best way to do this, as CFrame is instantaneous. If you want it to feel more physics-like, why not use roblox physics?

The easiest way to do this is by using a BodyPosition and unanchoring your part, updating the BodyPosition.Position instead of CFraming.

If you need to keep the part from rotating you can also use a BodyGyro. If you want to update the rotation you can change the BodyGyro.CFrame property

3 Likes

Wow. You just read my mind, I did this like right after I posted this question but it turned out that if you move it, it moves very blocky and not smooth. I’m just currently looking for ways to improve the smoothness without having to just move the camera very slowly.

1 Like