Tween plays as if TweenTime is 0

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)

bump.

extracharactersssssssssssssss

It’s because you’re firing the set remote first, then the tween remote immediately afterwards, and since RemoteEvents are received in the order they’re fired, the camera’s CFrame is set, and then tweened to the position it’s already in. That’s why there isn’t any transition.

Proximity.Triggered:Connect(function(whoTriggered)
	Events.TweenCamera:FireClient(whoTriggered, tweenConfig)
end)

Just remove the line firing the SetCamera remote and it should work just fine.

Also, you can keep all of this on the client by the way; clients can use the Triggered event of ProximityPrompts, though it only fires if the client triggers the prompt.

1 Like

How did I not notice that lol :sob:thx

1 Like

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