I attempted to make a script that activates and deactivates when a player stops moving/ starts moving respectively. This is my script. (Yes it's a local script)
local p = game.Players.LocalPlayer
repeat wait() until p.Character
local c = p.Character
local lastPos
local curPos
local dist
c.Torso.Changed:connect(--Whenever the player moves
function()
curPos = c.Torso.Position -- Current position
if lastPos and dist and dist < 1 then
wait(2)
if dist < 1 then -- If they're still in the same spot..
--Code here
end
end
lastPos = curPos -- Last spot
dist = (curPos-lastPos).magnitude -- Distance between last spot and current spot
end
)
I don't quite understand this kind of scripting, could someone help me out with it?

1 comment
This would not work. CFrame does not have a Changed event. Please don't reply if you don't know what you're doing.