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

How does one get something to fire when the position is at a certain point?

Asked by 5 years ago

So for example lets say I put wait(5) and then a part a normal part changed position to 49,59,10 and i wanted a event to fire when it became 49,59,10 does anyone know what i need to do to make a event or something fire when the position becomes 49,59,10

1
you could use instance's GetPropertyChangedSignal(property) and connect it to your function https://developer.roblox.com/api-reference/function/Instance/GetPropertyChangedSignal GoldAngelInDisguise 297 — 5y

1 answer

Log in to vote
4
Answered by
starmaq 1290 Moderation Voter
5 years ago

As gold said, for this you can use either :GetPropertyChangedSignal () or the Changed event, and I'm sure that you can just use an if statment that checks if part.Position is == to the position that you want. And to be honest i'd say that the best way (for me at least) to use the changed event. The paramater for this event, as guessed is the property that changed

local part = workspace.Part.  -- or wherever is your part

part.Changed:Connect(function(prop)
if prop == "Position" then -- we checked if the position was changed 
         if part.Position == Vector3.new(49, 59, 10) then -- then we checked if the position changed to the position we wanted
                    print(prop .. " changed to" .. tostring(part.Position))
                    -- and put what you want to be fired here
         end
end
end)

I'm aware that :GetPropertyChangedSignal() is more efficent but tbh i like it this way!

0
Sorry if my answer is weird looking im wrote this on a phone, and if you're wondering whats tostring for its prety much a function that changes any value to a string. its really helpful but not a difference if youre printing starmaq 1290 — 5y
0
oh boi 2 upvotes ty starmaq 1290 — 5y
Ad

Answer this question