I have a RemoteEvent
that fires from server code, which changes the TargetAngle
of a HingeConstraint
for one player. It’s triggered by the player colliding with a Part
. The HingeConstraint
controls a door that I want to open before the Player
teleports.
The event fires and is received correctly, and TargetAngle
is updated. The door behaves very oddly though.
Sometimes it opens. Sometimes is waits a little while. Sometimes it opens and closes at random. It feels as though there’s some conflict between the server value and the local value of TargetValue
.
How do I resolve this?
Server Code
if humanoid then
local player = getPlayerFromCharacter(partParent)
setVariableEvent:FireClient(player, hitbox.Door.HingeConstraint, "TargetAngle", -90)
end
Local Code
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local setVariableEvent = ReplicatedStorage.RemoteEvents.OneClient:WaitForChild("SetVariable")
local function onSetVariable(object, attribute, value)
object[attribute] = value
end
setVariableEvent.OnClientEvent:Connect(onSetVariable)
TIA