-
What do you want to achieve? Where at a distance, the npc will become invisible and create a particle for a brief moment
-
What is the issue? The script apparently is not running at a certain part?
-
What solutions have you tried so far? I tried using magnitude, and a few tutorialsā¦ none of which worked for my situation.
So here is my code and hierarchy (sorry if the code is messy )
local Root = script.Parent:WaitForChild("HumanoidRootPart")
local Human = script.Parent:WaitForChild("Humanoid")
local Sabbath = script.Parent
while wait() do
local e = game.Players:GetChildren()
for i, v in pairs(e) do
if v.Character then
if v.Character:FindFirstChild("HumanoidRootPart") then
if (v.Character.HumanoidRootPart.Position - Root.Position).magnitude<50 then
Human:MoveTo(v.Character.HumanoidRootPart.Position)
Root.Unsummon.Enabled = false
end
if(v.Character.HumanoidRootPart.Position - Root.Position).magnitude>50 then
Root.Unsummon.Enabled = true
Sabbath:GetChildren().Transparency = 1
end
end
end
wait()
end
end
--[[local function Disappear()
local dist = 20
local target = nil
for i,v in pairs (game.Workspace:GetChildren())do
local human = v:FindFirstChild("Humanoid")
local torso = v:FindFirstChild("HumanoidRootPart")
if human and torso and v ~= Sabbath then
if (Root.Position - torso.Position).magnitude > dist then
dist = (Root.Position - torso.Position).magnitude
target = torso
print("Out Of Range")
end
end
end
return target
end
while wait()do
local torso = Disappear()
if torso then
print("OutOfRange")
end
end]]--
function Attack()
local Arrow = Instance.new("MeshPart")
Arrow.CFrame = Sabbath.Head.CFrame
Arrow.Size = Arrow.Size + Vector3.new(0.85, 0.3, 0.27)
Arrow.Orientation = Arrow.Orientation + Vector3.new(0, 90, 0)
Arrow.Parent = Sabbath.Head
local weld = Instance.new("Weld")
weld.Part0 = Sabbath.Head
weld.Part1 = Arrow
weld.Parent = Arrow
weld.C0 = Sabbath.Head
weld.C1 = Arrow
end