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

Workspace.Dummy.Controller.Attack:12: Expected identifier when parsing expression, got ')'?

Asked by 3 years ago

Please encode Lua code in the Lua block code tag (look for the Lua icon in the editor).

local attackCooldown = 1 local attackWindup = 0.5 local attackRange = 3 local attackDamage = 20

local char = script.Parent.Parent local hum = char:WaitForChild("humanoid") local originalWalkSpeed = hum.WalkSpeed

local canAttack = true

script.Parent.AttackRemote.Event:Connect(function(plrRoot))

if not canAttack then return end canAttack = false

hun.Walkspeed = 0.1

local anim = Instance.new("Animation") anim.AnimationId = "rbxassetid://7209529782" local playAnim = hum:LoadAnimation(anim) plrRoot:Play()

wait(attackWindup) local newDistance = (char.HumanoidRootPart.Position - -plrRoot.Position).magnitude if newDistance <= attackRange + 5 then

if plrRoot.parent.Player.isBlocking.Value == true then
    attackDamage *= 0.5
end
plrRoot.Parent.Humanoid:takeDamage(attackDamage)

wait(attackCooldown) hum.WalkSpeen = orininalWalkSpeed canAttack = true

end

1 answer

Log in to vote
0
Answered by
JesseSong 3916 Moderation Voter Community Moderator
3 years ago
Edited 3 years ago

The error is very simple: On line 12, you added an extra closing bracket ) without closing it All you have to do is remove the extra closing bracket on line 12. Also, you're also missing an end)

Let me know if you have more issues!

~JesseSong

Fixed Code:

local attackCooldown = 1
local attackWindup = 0.5
local attackRange = 3
local attackDamage = 20

local char = script.Parent.Parent
local hum = char:WaitForChild("humanoid")
local originalWalkSpeed = hum.WalkSpeed

local canAttack = true

script.Parent.AttackRemote.Event:Connect(function(plrRoot)

if not canAttack then return end
canAttack = false

hun.Walkspeed = 0.1

local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://7209529782"
local playAnim = hum:LoadAnimation(anim)
plrRoot:Play()

wait(attackWindup)
local newDistance = (char.HumanoidRootPart.Position - -plrRoot.Position).magnitude
if newDistance <= attackRange + 5 then 

    if plrRoot.parent.Player.isBlocking.Value == true then
        attackDamage *= 0.5
    end
    plrRoot.Parent.Humanoid:takeDamage(attackDamage)

    wait(attackCooldown)
    hum.WalkSpeen = orininalWalkSpeed
    canAttack = true

end
end)
Ad

Answer this question