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

Make something happen when a parts position changes?

Asked by
blowup999 659 Moderation Voter
10 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?

2 answers

Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 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.

Ad
Log in to vote
0
Answered by
Azarth 3141 Moderation Voter Community Moderator
10 years ago

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)
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. User#2 0 — 10y

Answer this question