I have a script that when a player gets close to the npc it will enable a script and when the player is far it will disable a script but, it keeps on saying that the player is far from it.
server script in ServerScriptService:
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local NPC = game.Workspace:WaitForChild("Tank")
local Distance = (NPC:WaitForChild("HumanoidRootPart").Position - Character:WaitForChild("HumanoidRootPart").Position).Magnitude
while true do
wait(1)
if Distance <= 30 then
NPC.Script.Enabled = true
print("close")
else
NPC.Script.Enabled = false
print("Far")
end
end
end)
end)
robloxapp-20230804-1637457.wmv (1.5 MB)