How would I ensure a door's status is the same across clients?

A few months ago I made a post here in order to optimize a door script I was working on. After I implemented it I took a hiatus from that project and am now returning to it.

As the title states, how would I ensure that a door has the same status when tweening to every client rather than the server? Should I not worry about it? Or am I better off switching to tweening on the server?

Here is my script for the tweening:

local TweenService = game:GetService("TweenService")

game.ReplicatedStorage.Remotes.DoorEvent.OnClientEvent:Connect(function(Door)
	local DoorRoot = Door.DoorModel.PrimaryPart
	
	local DoorTweenInfo = TweenInfo.new(2,Enum.EasingStyle.Cubic,Enum.EasingDirection.Out)
	
	local DoorOpen = TweenService:Create(DoorRoot, DoorTweenInfo, {
		CFrame = DoorRoot.CFrame + DoorRoot.CFrame.UpVector * 8
	})
	
	local DoorClose = TweenService:Create(DoorRoot, DoorTweenInfo, {
		CFrame = DoorRoot.CFrame - DoorRoot.CFrame.UpVector * 8
	})
	
	if Door.Config.Open.Value == false then
		DoorRoot.DoorSound:Play()
		DoorOpen:Play()
		print("client: Door Opened!")
	elseif Door.Config.Open.Value == true then
		DoorRoot.DoorSound:Play()
		DoorClose:Play()
		print("client: Door Closed!")
	end
end)

Help is appreciated as always!

1 Like

Unless you are working on a real-time game where door’s status is really important, You should not worry about it, roblox also doesnt guarantee a player is at somewhere, maybe they lagged and they are behing you.

Also can i ask do you want to tween the door at the same milisecond for every player or do you want to ensure the door is open for all players?

The doors are somewhat important.

One of my big concerns that I should’ve put above is that somehow tries opening the door while someone else is behind, will it screw up the door?

Well I cannot say anything about it because I didnt try it, it also might depend on your code so i dont know. You might want to switch to tween on server if you want to ensure every client has same status of the door.

There are a lot of games on roblox that have doors in it, and have you seen something like door is open for you and for others its not, well probably not even if rarely. So yeah you shouldnt worry about it

I could add a function that executes after the tweening that automatically updates the door as a bit of a failsafe, but I’m still not sure if it’d be redundant or not.

What I do for my doors is have the server set state and the client tweens according to that state. Takes the remote out of the equation and simplifies your implementation.

A BoolValue specifically determines if the door is open or not, which the server sets. The client then listens to changes on this BoolValue and tweens the door according to the new value.

1 Like