How can I open door locally?

I have a vent door that is owned by server. But when the player has a tool and clicks on the vent door, I want the vent door to sort of burst open but only locally! This means that to other players, the vent door was never opened, only to this player it is.

I have a script that does work but since the door is owned by server, I have to be extremely close to the vent door for it to actually render bursting open. How can I make this really smooth?

The script (this is in a local script!):

Screwdriver.Activated:Connect(function()
	if Mouse.Target.Parent.Name == "VentOpen" then
		local VentDoor = Mouse.Target.Parent
		local Cloned = VentDoor:Clone()
		for i, v in pairs(VentDoor:GetChildren()) do
			if v.Name == "Hitbox" then
				v.Anchored = false
				v.AssemblyLinearVelocity = Vector3.new(0, 0, -50) -- This part does not render unless you are standing really close to the vent.
				task.wait(3)
				VentDoor:Destroy()
				print("Done")
			end
		end
	end
end)

When I stand close to the vent, it only renders the next frame. I have to move around for it to render more.

the reason you have to stand very close to it is because you are applying physics to a object that’s actually anchored. A way to solve this could be to either clone the vent and hide the real one, or manually animating the vent using cframe but that would be really inefficient

1 Like

The vent is not anchored. As you can see in the script, the vent does clone and replace itself when player dies.

Couple things you could do:

  1. This seems like a network ownership issue maybe, especially since the vent is not anchored, try setting the network owner to the player with the SetNetworkOwner method.

  2. You could place the vents entirely through the local script by just cloning them from ReplicatedStorage and then cframe them to their correct spots. It’d be entirely client-sided. This way every player has their own vents, and they can do whatever they want to them without other players seeing their changes.

I suggest turn this function into ServerSide
Screwdriver.Activated:Connect(function()

On Activated, fire a Remote to that client that runs a function to tween the door model. The door should be anchored.

you do clone it but you never actually use the clone version, you’re looping through the VentDoor not the Cloned and if this is a local script then yes you are unanchoring the parts but on the server they aren’t unanchored, therefore the parts will not be calculating physics on the server, only using your client, but it will not be using your client unless you’re close to the part. This is to save memory on the client, but because its anchored on the server it won’t calculate any physics

I do use the clone version when the player dies, to replace the vent but yes, I haven’t shown it in the script above. I do understand the client-server system, I just needed a solution to overcome this issue.

The 2nd option worked perfectly. I put all the stuff I want on the client into a folder in ReplicatedStorage. Then used a local script to clone them and place them in workspace.

Thank you so much!

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