can you please send a video of whatever you’re trying to replicate or the error because it looks like you’re making a camera follow a car, but you’ll need to loop it to make it keep following
2024-01-28 21-07-02 here is the video.
When the car stopped, it does what I want. But bugs when I try to do it while car is moving.
And the full code
local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local lookmode = false
local busy = false
wait(5)
local head = game.Workspace.Car.Main.Arms.Head
local firstcframe = game.Workspace.Car.Main.CFrame:ToObjectSpace(head.CFrame)
local camobjectspace = game.Workspace.Car.Main.CFrame:ToObjectSpace(workspace.Car.Main.Itself.Inside.LookCam.CFrame)
function input(inputkey, _gameProcessedEvent)
if inputkey.KeyCode == Enum.KeyCode.W then
game.ReplicatedStorage.SendSpeed:FireServer(true)
print("gave gas")
elseif inputkey.KeyCode == Enum.KeyCode.S then
game.ReplicatedStorage.SendSpeed:FireServer(false)
print("brake")
elseif inputkey.KeyCode == Enum.KeyCode.F then
if lookmode == false and busy == false then
busy = true
local tw = TweenService:Create(head,TweenInfo.new(0.7,Enum.EasingStyle.Sine,Enum.EasingDirection.Out),{CFrame = game.Workspace.Car.Main.CFrame:ToWorldSpace(camobjectspace)})
tw:Play()
tw.Completed:Wait()
lookmode = true
busy = false
print("lookstart")
elseif lookmode == true and busy == false then
busy = true
local tw = TweenService:Create(head,TweenInfo.new(0.7,Enum.EasingStyle.Sine,Enum.EasingDirection.Out),{CFrame = game.Workspace.Car.Main.CFrame:ToWorldSpace(firstcframe)})
tw:Play()
tw.Completed:Wait()
lookmode = false
busy = false
print("lookend")
end
end
end
UserInputService.InputBegan:Connect(input)
I’m taking the worldspace and objectspace for change its position based on the cars current position. But TweenService isn’t using the updated position. How can I achieve that?
The problem here is that it’s trying to tween to the old CFrame of the car, thus, lagging behind. If you simply want your camera to stay on the car, just set camerasubject to the car’s main part
If you still want to tween, I suggest hooking it up to a renderstepped and tweening there to make it follow smoothly. If that’s what you want, I’d be happy to give you another example.
Camera isn’t lagging while car is moving. The tweening process of the camera makes it lag, so it didn’t worked.
And I think the reason is because of my camera script. It changes the cframe of camera renderstepped to follow the car and also for special mouse effect.
Renderstepped makes sense, and I have to tween. I would be happy if you could give me an example about that.