I'm in need of help. I'm trying to make a game where a monster chases and attacks you to impress my friends. I'm trying to use a certain model, it came with this script but it won't work. I really don't know anything about this stuff, if anyone could help I would love it.

local SCP096Script=script;

repeat Wait(0);until script and script.Parent and script.Parent.ClassName=="Model"and script.Parent:FindFirstChild("Head")and script.Parent:FindFirstChild("Torso")and script.Parent:FindFirstChild("HumanoidRootPart");

local SCP096=SCP096Script.Parent;

if SCP096Script and SCP096 and SCP096:FindFirstChild("Thumbnail")then

SCP096:FindFirstChild("Thumbnail"):Destroy();

end

local Hush=SCP096:FindFirstChild("Hush");

local Notice=SCP096:FindFirstChild("Notice");

local SCP096Humanoid;

for _,Child in pairs(SCP096:GetChildren())do

if Child and Child.ClassName=="Humanoid"and Child.Health~=0 then

SCP096Humanoid=Child;

end;

end;

local CanSee=false;

local Pathing=false;

local SCP096Head=SCP096:FindFirstChild("Head");

local Damage5=SCP096Head:FindFirstChild("Damage5");

local Idle=SCP096Head:FindFirstChild("Idle");

local Panic=SCP096Head:FindFirstChild("Panic");

local Screaming=SCP096Head:FindFirstChild("Screaming");

local SCP096HumanoidRootPart=SCP096:FindFirstChild("HumanoidRootPart");

local SCP096Torso=SCP096:FindFirstChild("Torso");

local AttackDebounce=false;

local Chasing=false;

function raycast(Spos,vec,currentdist)

local hit2,pos2=game.Workspace:FindPartOnRay(Ray.new(Spos+(vec*.05),vec*currentdist),SCP096);

if hit2~=nil and pos2 then

if hit2.Name=="Handle" and not hit2.CanCollide or string.sub(hit2.Name,1,6)=="Effect"and not hit2.CanCollide then

local currentdist=currentdist-(pos2-Spos).magnitude;

return raycast(pos2,vec,currentdist);

end;

end;

return hit2,pos2;

end;

function RayCast(Position,Direction,MaxDistance,IgnoreList)

return Game:GetService("Workspace"):FindPartOnRayWithIgnoreList(Ray.new(Position,Direction.unit*(MaxDistance or 999.999)),IgnoreList);

end;

Spawn(function()

while Wait(0)do

if SCP096Script and SCP096 and SCP096HumanoidRootPart and SCP096Head and SCP096Humanoid and SCP096Humanoid.Health~=0 then

local TargetPoint=SCP096Humanoid.TargetPoint;

local Blockage,BlockagePos=RayCast((SCP096HumanoidRootPart.CFrame+CFrame.new(SCP096HumanoidRootPart.Position,Vector3.new(TargetPoint.X,SCP096HumanoidRootPart.Position.Y,TargetPoint.Z)).lookVector*(SCP096HumanoidRootPart.Size.Z/2)).p,SCP096HumanoidRootPart.CFrame.lookVector,(SCP096HumanoidRootPart.Size.Z*2.5),{SCP096,SCP096})

local Jumpable=false;

if Blockage then

Jumpable=true;

if Blockage and Blockage.Parent and Blockage.Parent.ClassName~="Workspace"then

local BlockageHumanoid;

for _,Child in pairs(Blockage.Parent:GetChildren())do

if Child and Child.ClassName=="Humanoid"and Child.Health~=0 then

BlockageHumanoid=Child;

end;

end;

if Blockage and Blockage:IsA("Terrain")then

local CellPos=Blockage:WorldToCellPreferSolid((BlockagePos-Vector3.new(0,2,0)));

local CellMaterial,CellShape,CellOrientation=Blockage:GetCell(CellPos.X,CellPos.Y,CellPos.Z);

if CellMaterial==Enum.CellMaterial.Water then

Jumpable=false;

end;

elseif BlockageHumanoid or Blockage.ClassName=="TrussPart"or Blockage.ClassName=="WedgePart"or Blockage.Name=="Handle"and Blockage.Parent.ClassName=="Hat"or Blockage.Name=="Handle"and Blockage.Parent.ClassName=="Tool"then

Jumpable=false;

end;

end;

if SCP096Script and SCP096 and SCP096Humanoid and SCP096Humanoid.Health~=0 and not SCP096Humanoid.Sit and Jumpable then

SCP096Humanoid.Jump=true;

end;

end;

end;

end;

end);

local DynamicWander=true;

while Wait(0)do

if SCP096Script and SCP096 and SCP096Humanoid then

SCP096Humanoid.CameraOffset=Vector3.new(0,0,0);

SCP096Humanoid.DisplayDistanceType="None";

SCP096Humanoid.HealthDisplayDistance=0;

SCP096Humanoid.Name="SCP";

SCP096Humanoid.NameDisplayDistance=0;

SCP096Humanoid.NameOcclusion="EnemyOcclusion";

SCP096Humanoid.Archivable=true;

SCP096Humanoid.AutoRotate=true;

SCP096Humanoid.MaxHealth=99999e99999;

SCP096Humanoid.Health=99999e99999;

SCP096Humanoid.JumpPower=0;

SCP096Humanoid.MaxSlopeAngle=90;

if not Chasing then

local SwitchWander=math.random(1,2000);

if SwitchWander==1 and not DynamicWander then

DynamicWander=true;

elseif SwitchWander==1 and DynamicWander then

DynamicWander=false;

end;

local WalkChance=math.random(1,100);

if WalkChance==2 and SCP096Script and SCP096 and SCP096:FindFirstChild("Torso")and SCP096:FindFirstChild("Head")and SCP096Humanoid and SCP096Humanoid.Health~=0 and not DynamicWander then

SCP096Humanoid:MoveTo(Game:GetService("Workspace"):FindFirstChild("Terrain").Position+Vector3.new(math.random(-2048,2048),0,math.random(-2048,2048)),Game:GetService("Workspace"):FindFirstChild("Terrain"));

elseif SCP096Script and SCP096 and SCP096Torso and SCP096Head and SCP096Humanoid and SCP096Humanoid.Health~=0 and DynamicWander then

local WanderAngle=(math.random()-0.5)*1;

local RotatingLookVector=CFrame.Angles(0,WanderAngle,0)*SCP096Torso.CFrame.lookVector;

SCP096Humanoid:MoveTo(SCP096Torso.Position+9*RotatingLookVector,SCP096Torso);

end;

SCP096Humanoid.WalkSpeed=3;

else

SCP096Humanoid=35;

end;

end;

if SCP096Script and SCP096 and Hush and Hush.IsPlaying then

Hush:Stop();

end;

if SCP096Script and SCP096 and Idle and not Idle.IsPlaying then

Idle:Play();

end;

if SCP096Script and SCP096 and Panic and Panic.IsPlaying then

Panic:Stop();

end;

if SCP096Script and SCP096 and Screaming and Screaming.IsPlaying then

Screaming:Stop();

end;

local NoticeDistance=5;

local TargetTorso;

for _,TargetModel in pairs(Game:GetService("Workspace"):GetChildren())do

if TargetModel.className=="Model"and TargetModel~=SCP096 and TargetModel.Name~=SCP096.Name and TargetModel:FindFirstChild("Torso")and TargetModel:FindFirstChild("Head")then

local TargetPart=TargetModel:FindFirstChild("Torso");

local FoundHumanoid;

for _,Child in pairs(TargetModel:GetChildren())do

if Child and Child.ClassName=="Humanoid"and Child.Health~=0 then

FoundHumanoid=Child;

end;

end;

if TargetPart and FoundHumanoid and FoundHumanoid.Health~=0 and(TargetPart.Position-SCP096HumanoidRootPart.Position).magnitude<NoticeDistance then

TargetTorso=TargetPart;

NoticeDistance=(TargetPart.Position-SCP096HumanoidRootPart.Position).magnitude;

AttackDebounce=true;

Spawn(function()

Chasing=true;

if SCP096Script and SCP096 and Idle then

Notice:Play();

end;

if SCP096Script and SCP096 and Hush and Hush.IsPlaying then

Hush:Stop();

end;

if SCP096Script and SCP096 and Idle and Idle.IsPlaying then

Idle:Stop();

end;

if SCP096Script and SCP096 and Panic then

Panic:Play();

end;

if SCP096Script and SCP096 and Screaming and Screaming.IsPlaying then

Screaming:Stop();

end;

SCP096Humanoid.WalkSpeed=0;

SCP096Humanoid:MoveTo(SCP096Torso.Position,Game:GetService("Workspace"):FindFirstChild("Terrain"));

Wait(38);

if SCP096Script and SCP096 and Hush and not Hush.IsPlaying then

Hush:Play();

end;

if SCP096Script and SCP096 and Idle and Idle.IsPlaying then

Idle:Stop();

end;

if SCP096Script and SCP096 and Panic and Panic.IsPlaying then

Panic:Stop();

end;

if SCP096Script and SCP096 and Screaming and not Screaming.IsPlaying then

Screaming:Play();

end;

SCP096Humanoid.WalkSpeed=35;

Spawn(function()

while Wait(0)do

local hit,pos=raycast(SCP096HumanoidRootPart.Position,(TargetPart.Position-SCP096HumanoidRootPart.Position).unit,500)

if hit and hit.Parent and hit.Parent.ClassName=="Model"and hit.Parent:FindFirstChild("Torso")and hit.Parent:FindFirstChild("Head")then

CanSee=true;

else

CanSee=false;

end;

end;

end);

repeat

Wait(0)

if CanSee then

SCP096Humanoid:MoveTo(TargetPart.Position+(TargetPart.Position-SCP096HumanoidRootPart.Position).unit*2,Game:GetService("Workspace"):FindFirstChild("Terrain"));

end;

if not CanSee and not Pathing then

Spawn(function()

Pathing=true;

local RenderedPath=game:GetService("PathfindingService"):ComputeRawPathAsync(SCP096Torso.Position,TargetPart.Position,500);

local RenderedPathCoordinates=RenderedPath:GetPointCoordinates();

for _=1,#RenderedPathCoordinates do

if not CanSee then

local Point=RenderedPathCoordinates[_];

local PathTimer=0;

repeat Wait(0);

SCP096Humanoid:MoveTo(Point);PathTimer=PathTimer+1;

if PathTimer>15 or CanSee then

break;

end;

until(SCP096Torso.Position-Point).Magnitude<5 or PathTimer>15 or CanSee;

if PathTimer>15 or CanSee then

break;

end;

end;

end;

Pathing=false;

end);

end;

if TargetModel and TargetPart and FoundHumanoid and FoundHumanoid.Health~=0 and (TargetPart.Position-SCP096HumanoidRootPart.Position).magnitude<10 then

Damage5:Play();

FoundHumanoid:TakeDamage(99999e99999);

end

until TargetModel.Parent==nil or TargetPart.Parent==nil or FoundHumanoid.Parent==nil or TargetModel and TargetPart and FoundHumanoid and FoundHumanoid.Health==0;

Chasing=false;

end);

repeat Wait(0);until not Chasing;

AttackDebounce=false

end;

end;

end;

end;

1 comment

0

Taken from free model