I wanted to check the range of the player from the generator, I used magnitude to see if the HumanoidRootPart is > The range of the generator, I was testing it But i came across that the output won’t print anything. Here’s my code.
local Generator = script.Parent
local Player = game.Players.LocalPlayer
local Character = Player.Character:WaitForChild("HumanoidRootPart")
local Distance = (Generator.Position - Character.Positon).Magnitude
while true do
wait()
print(Distance)
end
Unfortunately as of a update made a while ago, LocalScripts can’t run in the workspace. You need to put it in either StarterPlayerScripts, the Backpack, the Character, or StarterGui for it to run. This is a bit frustrating to work around, but it is very possible to shift LocalScripts to work from one of the working LocalScript locations.
Another option would be to use a Server Script, if that is a possibility for what you are trying to accomplish. A normal Script can be placed pretty much anywhere, except for local directories.