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

Make something happen when a parts position changes?

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?

2 answers

✓ Accepted answer

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.

To add to Arbitrator

--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
		print("add")
		stopped = true
	else
		stopped = false
	end
end)

1 comment

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.

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