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

I made a script for a enemy AI. but i have gotten a few errors...?

Asked by 4 years ago

here is my script:

local Zombie = game.ReplicatedStorage:FindFirstChild("Zombie")

local Attack = Zombie.AiScript local Humanoid = Zombie.Humanoid

local Player = game.Players local Players = Player.LocalPlayer

local Clicker = Zombie.ClickDetector

local function Attack() if Humanoid.Touched:Connect() then Player.Humanoid.Health = 0 elseif Player.Humanoid.Health == 100 end end

local function Attack()

local function Clicked(function() if Clicker.MouseButton1Down:Connect() Zombie.Humanoid.Health = 0 elseif Zombie.Humanoid.Health = 100 end)

local function Clicked()

it says: 14:13:07.961 - Workspace.Zombie.AiScript:18: Expected 'then' when parsing if statement, got 'end'

...Pls Help!!!

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Here I Corrected Your Code. Comment If It Doesn't Work. I Edited It You Did Not Run The Function When The Person Clicks.

local Zombie = game.ReplicatedStorage:FindFirstChild("Zombie")

local Attack = Zombie.AiScript

local Humanoid = Zombie.Humanoid

local Player = game.Players

local Players = Player.LocalPlayer.Character

local Clicker = Zombie.ClickDetector

local function Attack()
    if Humanoid.Touched:Connect() then
        Player.Humanoid.Health = 0
    else
        if Player.Humanoid.Health == 100 then
            --Your Other Function Here
        end
    end
end

local function Clicked()
    if Clicker.MouseButton1Down:Connect() then
        Zombie.Humanoid.Health = 0 
    else
        if Zombie.Humanoid.Health == 100 then
            --Your Other Code Piece Here I Guess
        end
    end
end
0
Alright. So it seems to work, until I tried to click the zombie to kill it...It didn't do anything... User#32650 0 — 4y
0
Oh AmazingAmazingArthur 15 — 4y
0
yeah... :/ User#32650 0 — 4y
0
I'm thinking os using a break joint function, but I'm not too sure how to use it... User#32650 0 — 4y
View all comments (4 more)
0
Aight! Thank you very much for your help! User#32650 0 — 4y
0
Your Welcome You Can Contact Me At Lua#8082 Any Time On Discord If You Need Help For Future Scripts. AmazingAmazingArthur 15 — 4y
0
ok :) User#32650 0 — 4y
Ad

Answer this question