0

# Make something happen when a parts position changes?

blowup999 562
7 years ago

Is it possible to make a function happen whenever a parts position changes, like lets say every time i move my torso i get .5 more walkspeed?

1
7 years ago

You used to be able to use the Changed event for this, but some time ago ROBLOX disabled it for properties that update too frequently. As in, they caused server lag when the even was connected. Part Positions were one of the properties cut.

You'll have to listen to some other event, for example the Running event of the Humanoid, and calculate the change in Position once it fires.

If you want to have the event fire when some arbitrary part moves, you're out of luck as far as I know, unless you can figure out some other event to listen to.

0
Azarth 3113
7 years ago

--If you want it to be for your character, you can use this event.

repeat wait() until game.Players.LocalPlayer and game.Players.LocalPlayer.Character
local p = game.Players.LocalPlayer
local c = p.Character
local h = c.Humanoid
local stopped = false

h.Running:connect(function() -- The problem with this is that it also fires when you stop, but I fixed that.
if not stopped then
h.WalkSpeed = h.WalkSpeed + .5
stopped = true
else
stopped = false
end
end)

0
It gives an parameter; speed. This speed is the speed the character is going at when Running is fired. 0 means stopped, anything else is that speed they're going at. Everesty 1001 — 7y