Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make doors open when Character gets near?

Asked by 8 years ago

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.

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. Scootakip 299 — 8y
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. RubyQube 10 — 8y

1 answer

Log in to vote
1
Answered by
Sparker22 190
8 years ago

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.

Ad

Answer this question