Problem when opening a door in localscript (script+video)

Hello, my problem is the following, in fact in the video when the second player takes the tool and touches the part then the door disappears for him but not for the second player who has a tool and who is placed on the other part, and conversely. It is only the player who comes last who sees the door disappear. What I would like is that the door opens for the two players with the tool but not for the other players of the servers. I sent a small part of the script and an “explanatory” video. I have tried many different scripts, some open the door for everyone, others the box lights up locally so the script doesn’t work properly. Thanks

local plr = game.Players.LocalPlayer
local debounce = 1

local transparent = function()
	if debounce == 1 then
		debounce = 2
		game.Workspace.Door2.Transparency = 1
		wait(60)
		game.Workspace.Door2.Transparency = 0 
	end
	if not debounce == 1 then end
end;

local function onTouch(hit)
	if hit.Parent.Name == "Wrench2" then
		game.Workspace.Clefv.Material = Enum.Material.Neon
	    end
	if hit.Parent.Name == plr.Name then 
		if game.Workspace.Clefv.Material == Enum.Material.Neon and game.Workspace.Clefv3.Material == Enum.Material.Neon then
			transparent()
		end
	end
end
 
game.Workspace.Clef.Touched:Connect(onTouch)

local function onTouch(hit)
	if hit.Parent.Name == "Wrench3" then
		game.Workspace.Clefv3.Material = Enum.Material.Neon
	end
	if hit.Parent.Name == plr.Name then
		if game.Workspace.Clefv.Material == Enum.Material.Neon and game.Workspace.Clefv3.Material == Enum.Material.Neon then
			transparent()
		end
	end
end

You could try use a remote function to send the event to the server and return back. More info on the article.

1 Like

oh ok I’m not familiar with this yet (I’m pretty new as a scripter) I’ll try to watch some tutorials about it, thanks. Do you think this is the only way to be able to do this?

From my understanding, you only want the door to open for two players, not everyone.

So from that case, the only way you would go about doing this is by communicating with the local and server side, which is either a Remote Event or Remote Function.

1 Like

Thank you, I will watch tutorial videos of these two features that I do not master at all

1 Like