I need to send a tween to a client when a proximity is triggered, and when it plays it should play a tween on the camera to a certain parts CFrame. But it acts like tween time is 0 and doesn’t have a tween…
ServerScript:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Events = ReplicatedStorage.Events
local Proximity = script.Parent
local PurchaseCamera = Proximity.Parent.Parent.PurchaseCamera
local cameraConfig = {
CameraType = Enum.CameraType.Scriptable,
CameraSubject = PurchaseCamera,
CameraCFrame = PurchaseCamera.CFrame
}
local tweenConfig = {
TweenTo = PurchaseCamera.CFrame,
tweenInfo = {
1,
Enum.EasingStyle.Sine,
Enum.EasingDirection.InOut,
0,
false,
0
}
}
Proximity.Triggered:Connect(function(whoTriggered)
Events.SetCamera:FireClient(whoTriggered, cameraConfig)
Events.TweenCamera:FireClient(whoTriggered, tweenConfig)
end)
ClientScript:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local Events = ReplicatedStorage:WaitForChild("Events")
local SetCameraEvent = Events:WaitForChild("SetCamera")
local TweenCameraEvent = Events:WaitForChild("TweenCamera")
local CurrentCamera = workspace.CurrentCamera
SetCameraEvent.OnClientEvent:Connect(function(config)
local CameraType = config["CameraType"]
local CameraSubject = config["CameraSubject"]
local CameraCFrame = config["CameraCFrame"]
CurrentCamera.CameraType = CameraType
CurrentCamera.CameraSubject = CameraSubject
CurrentCamera.CFrame = CameraCFrame
end)
TweenCameraEvent.OnClientEvent:Connect(function(config)
print(config)
local TweenCFrame = config["TweenTo"]
local tweenInfo = config["tweenInfo"]
local tween = TweenService:Create(CurrentCamera, TweenInfo.new(table.unpack(tweenInfo)), {CFrame = TweenCFrame})
tween:Play()
end)