I have a folder in workspace which contains all of the door models in my SCP:F Site which are a lot. I am trying to create a script that makes text appear on your screen saying "Press E to Open" when you are within 10 studs. The script is this:
local function checkIfNear()
for i = 1, #eachDoor do
local touchpart = eachDoor[i].Toucher
if LocalPlayer:DistanceFromCharacter(touchpart.Position) < 10 then
print("close to door")
RunService:UnbindFromRenderStep("ifNearBind")
elseif LocalPlayer:DistanceFromCharacter(touchpart.Position) > 10 then
print("not close to door")
end
end
end
RunService:BindToRenderStep("ifNearBind", 300, checkIfNear)
I had it so when I went by a door, it would print "close to door" over and over, hundreds of times. That's why I am attempting to use UnbindFromRenderStep and BindToRenderStep to stop it from doing that as I only want it to do the actions once when you're inside the 10 studs, and then do an action once when you leave. It works and does the print("close to door") once, but I don't know how to get it to keep running and detect when left, and then when you go back again. I've done a lot of devforum looking and still haven't came across an answer as to how I would go about that.
