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

Falling Part Not Activating :Changed ?

Asked by 5 years ago
Edited 5 years ago

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?

0
Position doesn't fire Changed. User#19524 175 — 5y
0
Why not? It seems to trigger when going up jonathan1q2w3e4r 4 — 5y

1 answer

Log in to vote
1
Answered by
amanda 1059 Moderation Voter
5 years ago
Edited 5 years ago

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

0
You're back! User#19524 175 — 5y
Ad

Answer this question