Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make doors open when Character gets near?

Hello.

I'm not an experienced scripter at all, so forgive me if this is easy. I need some help on door opening. What I want to happen is when a character (aka robloxian) gets close to a door, they open automatically. I want the doors to open like automatic doors.

If anyone could help me with this it would be great!

Thanks.

2 comments

0

This isn't a request site, OK? If you want help you need to show proof that you've already made an attempt at this.

0

Stop kid. I barely know how to script so I want to learn how to do this. I'm not requesting anything, how could I script this if I barely even know how to script? Tell me you immature brat.

1 answer

There are 2 methods you can do for this.

You can do a magnitude check. The formula for getting the distance for the parts is as follows.

local Vec = Position1 - Position2
local Distance = math.sqrt(Vec.x^2,Vec.y^2,Vec.z^2)
local Distance = Vec.magnitude -- alternative.

Vector3 values has a .magnitude property so you could just use Vec.magnitude as well. This would require constant checking so be wary of that. Doing this client-sided if possible would work.

The 2nd method is putting an invisible part in front of the door then hooking a .Touched event to it that triggers the door.

This discussion is preserved as it was. New answers, comments, and votes are closed.