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

magnitude script doesn't work player>part. HELP?

local torso = game.Players.LocalPlayer.Character:FindFirstChild("Torso")
while wait (2) do
	print(game.Workspace.dick.Position - torso.magnitude)
end

I dont know how to use "FindFirstChild", but im pretty sure the script is supposed to measure the player position to the part position but there is an error

- Players.Not_Paulo.PlayerGui.LocalScript:3: attempt to index nil with 'magnitude'

3 comments

0

Are you using r15? If you are, you want to use HumanoidRootPart instead of Torso.

0

o but did you read the error

0

You're trying to measure the distance between the torso and the uh... what now? (game.Workspace.d___.Position - torso.Position).Magnitude returns the distance between the two objects' positions.

1 answer

Well, it looks like you are indexing magnitude without indexing Position. And I assume you are trying to find the magnitude between the two parts. In your case, you must have a R6 character. For R15, just put HumanoidRootPart instead of Torso. So, here's an example that might help:

local part1 = workspace.PartA
local part2 = workspace.PartB

local magnitude = (part1.Position - part2.Position).Magnitude

print(magnitude)

Lemme know if it helps!

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