Easy Written By SintzTutchz

Only player door Created on: 11-02-2020

This shows you how to make a part "open" when a specific player touches it.

Do you know tycoon doors that only a specific player can pass through it? This is the idea: make a specific player pass through the part (you can make designs for it if you want. Everything you have to do is put this inside the part that will be opened).

>This isn't a tycoon door.

>Other players can pass it if it's opened.

>If it isn't working, check if you wrote correctly the player's name.

Let's start

So first, you need to get or create your part that will be the door. You can name it whatever you want, but I'll name mine "Door"(the name wont be used in the script). After it you create a script inside it. Now you might ask: "How am I doing the door open?". It's pretty simple: you just need to create an event to detect when player touches it. Then, it starts:

script.Parent.Touched:Connect(function(hit)

end)

Perfect. Now it is checking if the player has touched the part. If you run, nothing happens. How do we check if the player whose touched is the one that I want? For this case, we are using the if .

script.Parent.Touched:Connect(function(hit)
	if hit.Parent.Name == "" then --Put the player's name inside the quotes

	end
end)

Now it is checking if the player's name is the one that you've chosen. If you run, nothing happens again. "But we have detected if the player touched the part!". Yes, we do, but we didn't tell it what should happen now. For this case, we need to make some customizations on our door. You can choose some of them for whatever you want, but not all of them. I'll write what you can change:

script.Parent.Touched:Connect(function(hit)
	if hit.Parent.Name == "" then
		script.Parent.CanCollide = false --Don't change.
		script.Parent.Transparency = 0.7 --You can change.
		wait(1.4) --You can change.
		script.Parent.CanCollide = true --Don't change
		script.Parent.Transparency = 0 --You can change.
	end
end)

So, what is happening here? When we used CanCollide for the first time, we changed the Door property so it can't be collided (players can pass through it), then when we used the second time, we chaned it to can be collided (players can't pass through it). When we used Transparency, we are doing what the names supposes: change the transaprency of the Door. If we set it to 1 the Door will be invisible, and the lower it is, more visible it becomes. (Remember that 0 is the lowest and 1 the highest)

Done! Now you have a door that will open when this player touches it. Again, other players can pass it if it's opened, and that's why I put 1.4 seconds to it close again.

This is it

Thank you for reading this. Hope you learnt how to make it ;)

Easy Written By SintzTutchz

See SintzTutchz's profile on Roblox

Discussion