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

This Magnitude script isnt working, I can't see why?

It should work but it's not printing "it works" when I walk within 10 studs of the brick.. I've looked through this various times, and can't see a problem.

if (game.Players.LocalPlayer.Character:FindFirstChild("Torso").Position-workspace.wheatground.Position).magnitude<10 then
print("it works")
end

2 answers

Make sure it's in a loop that checks periodically, that's all that I can think of

Try binding it to the game's runservice, if you haven't already, so it's constantly checking.

local runService = game:GetService("RunService")

function CheckForDist()
	if (game.Players.LocalPlayer.Character:FindFirstChild("Torso").Position -
		workspace.wheatground.Position).magnitude<10 then
		print("it works")
	end
end
runService.Stepped:connect(CheckForDist)

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