How do i make the attack only hit npcs? Someone please help me
Wave.Touched:Connect(function(hit)
if hit:IsA("MeshPart") or hit:IsA("Part") then
if not hit:IsDescendantOf(game.Workspace.Mobs.NPC) then
local EHum = hit.Parent:FindFirstChild("npchum")
if EHum then
if EHum:FindFirstChild(EHum) then
local debounce = Instance.new("BoolValue", EHum)
debounce.Name = "Debounce"
Debris:AddItem(debounce,.75)
EHum:TakeDamage(Damage)
end
end
end
end
end)
local Debris = game:GetService("Debris")
local Players = game:GetService("Players")
local function FindHumanoid(hit)
local part = hit.Parent
if part:FindFirstChild("Humanoid") then
return part:FindFirstChild("Humanoid")
elseif part.Parent:FindFirstChild("Humanoid") then
return part.Parent:FindFirstChild("Humanoid")
end
end
Wave.Touched:Connect(function(hit)
local human = FindHumanoid(hit)
if human then
if not Players:GetPlayerFromCharacter(human.Parent) then -- Make sure it's not a player
if human:FindFirstChild("IsNPC") and not human:FindFirstChild("Debounce") then -- You could insert a boolvalue inside the npcs humanoid for double check
local debounce = Instance.new("BoolValue", human)
debounce.Name = "Debounce"
Debris:AddItem(debounce, .75)
human:TakeDamage(10)
end
end
end
end)
local Debris = game:GetService("Debris")
local Players = game:GetService("Players")
local function FindHumanoid(hit)
local part = hit.Parent
if part:FindFirstChild("npchum") then
return part:FindFirstChild("npchum")
elseif part.Parent:FindFirstChild("npchum") then
return part.Parent:FindFirstChild("npchum")
end
end
Wave.Touched:Connect(function(hit)
local human = FindHumanoid(hit)
if human then
if not Players:GetPlayerFromCharacter(human.Parent) then -- Make sure it's not a player
if human:FindFirstChild("IsNPC") and not human:FindFirstChild("Debounce") then -- You could insert a boolvalue inside the npcs humanoid for double check
local debounce = Instance.new("BoolValue", human)
debounce.Name = "Debounce"
Debris:AddItem(debounce, .75)
human:TakeDamage(10)
end
end
end
end)
local rp = game:GetService("ReplicatedStorage")
local detroit = rp.Events:WaitForChild("Skill1")
local TweenService = game:GetService("TweenService")
local Debris = game:GetService("Debris")
local cam = rp.Events:WaitForChild("Camm")
local Damage = 20
local Animation = script:WaitForChild("Animations")
local Meshes = script:WaitForChild("Meshes")
detroit.OnServerEvent:Connect(function(player)
local Character = player.Character
local humanoid = Character:WaitForChild("Humanoid")
local HumRP = Character:WaitForChild("HumanoidRootPart")
local smash = humanoid:LoadAnimation(Animation.Animated)
smash:Play()
local Effects = Instance.new("Folder", Character)
Effects.Name = "Effects"
Debris:AddItem(Effects,3)
smash.KeyframeReached:Connect(function(PunchFrame)
local Wave = Meshes:WaitForChild("Wave"):Clone()
Wave.CFrame = HumRP.CFrame * CFrame.new(0,0,-3)
Wave.Parent = Effects
Debris:AddItem(Wave,.75)
spawn(function()
cam:FireClient(player)
end)
local sound = Instance.new("Sound",Character)
sound.SoundId = "rbxassetid://464615492"
sound:Play()
Debris:AddItem(sound,.75)
local goal = {}
goal.Size = Wave.Size + Vector3.new(3,3,4)
local info = TweenInfo.new(.25)
local tween = TweenService:Create(Wave,info,goal)
tween:Play()
local goal2 = {}
goal2.CFrame = Wave.CFrame * CFrame.new(0,0,-75)
goal2.Transparency = Wave.Transparency + (1 - Wave.Transparency)
local info2 = TweenInfo.new(.75,Enum.EasingStyle.Linear)
local tween2 = TweenService:Create(Wave,info2,goal2)
tween2:Play()
local function FindHumanoid(hit)
local part = hit.Parent
if part:FindFirstChild("npchum") then
return part:FindFirstChild("npchum")
elseif part.Parent:FindFirstChild("npchum") then
return part.Parent:FindFirstChild("npchum")
end
end
Wave.Touched:Connect(function(hit)
local human = FindHumanoid(hit)
if human then
if not player:GetPlayerFromCharacter(human.Parent) then -- Make sure it's not a player
if human:FindFirstChild("IsNPC") and not human:FindFirstChild("Debounce") then -- You could insert a boolvalue inside the npcs humanoid for double check
local debounce = Instance.new("BoolValue", human)
debounce.Name = "Debounce"
Debris:AddItem(debounce, .75)
human:TakeDamage(10)
end
end
end
end)
for i=1, 25 do
local Rocks = Meshes:WaitForChild("Rocks"):Clone()
Rocks.CFrame = Wave.CFrame * CFrame.new(0,-3,0)
Rocks.Parent = Effects
Debris:AddItem(Rocks,3)
local rGoal = {}
rGoal.Transparency = Rocks.Transparency + (1- Rocks.Transparency)
local rInfo = TweenInfo.new(3)
local rTween = TweenService:Create(Rocks,rInfo,rGoal)
rTween:Play()
wait()
end
end)
detroit:FireClient(player)
end)
if hitpart.Parent:FindFirstChild("Humanoid") then
local Character = hitpart.Parent
local player = game.Players:GetPlayerFromCharacter(Character)
if player then return end
-- your code
end
Wave.Touched:Connect(function(hit)
if hit:IsA("BasePart") then
if not hit:IsDescendantOf(game.Workspace.Mobs.NPC) then
local EHum = hit.Parent:FindFirstChild("npchum")
if EHum then
local debounce = Instance.new("BoolValue", EHum)
debounce.Name = "Debounce"
Debris:AddItem(debounce,.75)
EHum:TakeDamage(Damage)
end
end
end
end)