I'm making playbackspeed of a sound increase when near a player and decrease when further away from a player. I tested it on a part measuring distance from your character to a part
sound.PlaybackSpeed = (game.Workspace.Part.Position + humanoidrootpart.Position).magnitude/60
It worked and then I tested it on a r15 player model and the playbackspeed decreased when getting closer and increased when getting further away and I can't find a way to fix it
while wait() do
for i, v in pairs(game.Players:GetPlayers()) do
if v.Character:FindFirstChild("Humanoid") then
sound.PlaybackSpeed = (v.Character.HumanoidRootPart.Position + root.Position).magnitude/60
end
end
end
the script is local

3 comments
To determine the distance between two points, you must subtract.
Think of it as a generic mathematical problem: Solve for the distance between 8 & 15. (15 - 8 = 7), adding does you no good.
Except when I change it to (v.Character.HumanoidRootPart.Position - root.Position).magnitude it still increases when I get further away and decreases when I get closer to the character