01 | char.Torso.Changed:connect( function (prop) |
02 | if prop = = "Position" then |
03 | local dis = (block.Position-char.Torso.Position).magnitude |
04 | if dis < = maxDistance then |
05 | gui.Frame.Visible = true |
06 | print "Now you see me" |
07 | else |
08 | gui.Frame.Visible = false |
09 | print "Now you dont" |
10 | end |
11 | end |
12 | end ) |
Within the output it prints "Now you dont" "Now you dont" and then terminates.
EDIT: If it helps, here's the entire script
01 | local player = game.Players.LocalPlayer |
02 | if not player.Character then player.CharacterAdded:wait() end |
03 | local char = player.Character |
04 | block = game.Workspace:WaitForChild( "Door" ) |
05 | local maxDistance = 100 |
06 | local gui = player.PlayerGui.Text |
07 | local WaitTime = 0.001 |
08 | local inProcess = false |
09 | local active = false |
10 |
11 | function open() |
12 | for i = 0 , 22 do |
13 | block.CFrame = block.CFrame + Vector 3. new( 0 ,. 5 , 0 ) |
14 | wait(WaitTime) |
15 | end |
Changed doesn't fire for Physics
If I recall correctly
It's annoying, and it's also incredibly stupid. The only real way you're going to get those sorts of things checked is with a polling loop. Sorry about that. You'll have to look for a different event to check (How about one from the Humanoid?), or use a while loop.
I used MoveDirection
under the LocalPlayer's Humanoid. It only has a value when the player is moving.