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

Falling Part Not Activating :Changed ?

So I run a script that gives me the Y position of a part activated by a Changed event.

script.Parent.Changed:Connect(function()

local y = script.Parent.Position.Y

print(y)

end)

I also run a script that makes the part go up

for i = 0,2,x do

wait()

script.Parent:TranslateBy(Vector3.new(0,i,0))

end

then I have a script that unanchors the part

script.Parent.Anchored = false

When I run the script, it functions perfectly on the way up, giving me the Y position on the way up. But when it starts falling, it stops outputting values. Does the changed event not fire on the effect of gravity? If so is there any way to make the script fire as its falling?

2 comments

0

Position doesn't fire Changed.

0

Why not? It seems to trigger when going up

1 answer

✓ Accepted answer

The Changed event is immune to ROBLOX physics.

What this means, is that if you change a part's properties through a script, it will trigger the event. However, if you let a part simply fall or interact with other parts, it will not trigger the event.

To get around this, you need to do one of two things:

  1. Simulate your own physics
  2. Check the Position of the part through script in increments for the portion of time you expect it to be interacting with physics.

What I mean for the second one, is you want to pretty much check the position every fraction of a second, and use that position accordingly. However, you do not want to check the position every fraction of a second for your entire game, as this can be heavy on server resources.

To counteract this, determine roughly how long it takes the part to fall, and check the position every increment until your goal time is reached.

unanchor part -> loop -> check position -> wait increment -> end

1 comment

0

You're back!

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