Proximity LocalScript not functioning

  1. What do you want to achieve?
    When the user walks close to the object, the print stuff gets executed.

  2. What is the issue?
    Nothing happens, no errors, nothing to indicate anything wrong but the script clearly isn’t running.

  3. What solutions have you tried so far?
    I couldn’t find anything related to my topic or my problem.

local plr = game:GetService("Players")
local obj = script.Parent
local localPlr = plr.LocalPlayer
local char = localPlr.Character or localPlr.CharacterAdded:Wait()

while true do
	if (char.HumanoidRootPart.Position - obj.Position).Magnitude <= 5 then
		print("If this prints then you're a genius bud")
	end
	wait(1)
end
	


Other information

  • The object is a mesh, the localscript is inside the mesh
  • changing the obj’s position in the if to CFrame.Position does not work either.

Localscripts do not run in workspace.

Ah I see, would I still be able to point the obj to the workspace?
i.e. game.Workspace.ObjNameHere

yes but you can just use workspace.ObjNameHere

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.