Im having some trouble with a script that when you sit in the car your camera zooms out and when you leaves the camera gets closer, to add an extra effect i thought in the camera just not sudden changes but gradually, but as always, it never works
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("CameraVehicle")
remoteEvent.OnClientEvent:Connect(function(seated)
if seated then
for zoom = 10, 27, .1 do
player.CameraMaxZoomDistance = zoom
player.CameraMinZoomDistance = zoom
end
else
for zoom2 = 27, 10, -.1 do
player.CameraMaxZoomDistance = zoom2
player.CameraMinZoomDistance = zoom2
end
end
end)
1 Like
Use Tween
s:
local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("CameraVehicle")
remoteEvent.OnClientEvent:Connect(function(seated)
if seated then
TweenService:Create(
player,
TweenInfo.new(
1, -- the time that the tween takes in seconds
Enum.EasingStyle.Linear, -- The EasingStyle
Enum.EasingDirection.Out, -- the EasingDirection
0, -- how many times the tween will repeat after once
false, -- tween won't reverse after reaching it's goal
0 -- delay time
),
{CameraMaxZoomDistance = 27, CameraMinZoomDistance = 27}
):Play()
else
TweenService:Create(
player,
TweenInfo.new(
1, -- the time that the tween takes in seconds
Enum.EasingStyle.Linear, -- The EasingStyle
Enum.EasingDirection.Out, -- the EasingDirection
0, -- how many times the tween will repeat after once
false, -- tween won't reverse after reaching it's goal
0 -- delay time
),
{CameraMaxZoomDistance = 10, CameraMinZoomDistance = 10}
):Play()
end
end)
3 Likes