I am trying to get the distance between a player's HumanoidRootPart and the main fireplace part so that I can make it so that you can light the torch up it in a certain range. I've been trying lots of methods recently for example Roblox's method.
local magnitude = (part1.Position - part2.Position).magnitude while true do if magnitude<5 then --- code --- end end
I've replaced part1 and part2 with my parts and it did not work. I've also tried a different method posted on this website 3 years ago.
local player = game.Players.Player1 local radius = 5 if player:DistanceFromCharacter(part) < radius then print('player is within radius') end
I've also replaced part with my part and it did not work either. Is this a problem or are my scripting skills still under a rock?
while wait(1) do local magnitude = (game.Players.LocalPlayer.Character.HumanoidRootPart.Position - game.Workspace:FindFirstChild("Baseplate").Position).magnitude if magnitude<5 then print("HOLY COW!!!") end end --distance between character and baseplate local script