Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I make a npc use this ability?

Asked by 4 years ago

https://gyazo.com/86e133d4c6b4c42f5df6729bb4179708

I want npc to use this attack. but I do not know where to start

Someone can help me ?

theses are the code

local script

local plrs = game:GetService("Players")
local player = plrs.LocalPlayer
local uis = game:GetService("UserInputService")
local Mouse = player:GetMouse()
local tool = player.Backpack:FindFirstChild("Ninja")
local remote = game.Workspace.Events.Ninja

if tool then

    uis.InputBegan:Connect(function(key)
        if key.KeyCode == Enum.KeyCode.G then
            remote:FireServer(Mouse.Hit)
        end
    end)

end

script

game.Workspace.Events.Ninja.OnServerEvent:Connect(function(player, Mouse)

    print("Ninja")

    local shuriken = game.ReplicatedStorage.ninja:Clone()

    shuriken.Parent = game.Workspace

    shuriken.Anchored = true

    shuriken.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0,1,0)

    local shuriken1 = shuriken:Clone()

    shuriken1.Parent = game.Workspace

    shuriken1.Anchored = true

    shuriken1.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(-3,1,4)

    local shuriken2 = shuriken:Clone()

    shuriken2.Parent = game.Workspace

    shuriken2.Anchored = true

    shuriken2.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(3,1,4)

    shuriken.Anchored = false

    local bv = Instance.new("BodyVelocity", shuriken)

    bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)

    bv.Velocity = Mouse.lookVector * 80

    shuriken1.Anchored = false

    local bv = Instance.new("BodyVelocity", shuriken1)

    bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)

    bv.Velocity = Mouse.lookVector * 80

    shuriken2.Anchored = false

    local bv = Instance.new("BodyVelocity", shuriken2)

    bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)

    bv.Velocity = Mouse.lookVector * 80

    shuriken.Touched:Connect(function(h)

    local roi = h.Parent:FindFirstChild("Part")

        local hrp = h.Parent:FindFirstChild("HumanoidRootPart") or h.Parent:FindFirstChild("Torso")

        if h.Parent:FindFirstChild("Humanoid") ~= nil and h.Parent then

        if h.Parent.Name == player.Name then return end

        h.Parent.Humanoid:TakeDamage(30)

        shuriken:Remove()

        if not hrp then

            print("Parede")

        end

        if hrp then

        print("Player get")

        local plasma = game.ReplicatedStorage.alek:Clone()

        plasma.Parent = game.Workspace

        plasma.Position = hrp.Position

        local explo = game.ReplicatedStorage.plasma:Clone()

        explo.Parent = game.Workspace

        explo.Position = hrp.Position

        local teen = game:GetService("TweenService")

        local i = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)

        local pro = {
            Size = Vector3.new(100,100,100),
            Transparency = 1
        }

        local start = teen:Create(explo,i,pro)

        start:Play()

        wait(1.5)

        plasma:Remove()

        end

        end

     end)

    shuriken1.Touched:Connect(function(h)

     local hrp = h.Parent:FindFirstChild("HumanoidRootPart") or h.Parent:FindFirstChild("Torso")

        if h.Parent:FindFirstChild("Humanoid") ~= nil and h.Parent then

        if h.Parent.Name == player.Name then return end

        h.Parent.Humanoid:TakeDamage(30)

        shuriken1:Remove()

        if not hrp then

            print("Parede")

        end

        if hrp then

        print("Player get")

        local explo = game.ReplicatedStorage.plasma:Clone()

        explo.Parent = game.Workspace

        explo.Position = hrp.Position

        local teen = game:GetService("TweenService")

        local i = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)

        local pro = {
            Size = Vector3.new(100,100,100),
            Transparency = 1
        }

        local start = teen:Create(explo,i,pro)

        start:Play()

        end

        end

     end)

    shuriken2.Touched:Connect(function(h)

        local hrp = h.Parent:FindFirstChild("HumanoidRootPart") or h.Parent:FindFirstChild("Torso")

        if h.Parent:FindFirstChild("Humanoid") ~= nil and h.Parent then

        if h.Parent.Name == player.Name then return end

        h.Parent.Humanoid:TakeDamage(30)

        shuriken2:Remove()

        if not hrp then

            print("Parede")

        end

        if hrp then

        print("Player get")

        local explo = game.ReplicatedStorage.plasma:Clone()

        explo.Parent = game.Workspace

        explo.Position = hrp.Position

        local teen = game:GetService("TweenService")

        local i = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)

        local pro = {
            Size = Vector3.new(100,100,100),
            Transparency = 1
        }

        local start = teen:Create(explo,i,pro)

        start:Play()

        end

        end

     end)

    wait(2)

    shuriken:Remove()
    shuriken1:Remove()
    shuriken2:Remove()
end)
0
You can start by having named functions. Try making use of OOP so you can reuse the same code within multiple instances i.e Player's and NPC's pidgey 548 — 4y
0
can u add me in discord, godne #5196 Goodbye_Fx 29 — 4y

Answer this question