The output says it needs an end but I dont know where to put it nor where it needs an end
The exact error is "end" expected(to close "function" at line 12) ner ""
Heres the code
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local KeyQPressedEvent = script.Parent.KeyQPressed
local KeyEPressedEvent = script.Parent.KeyEPressed
local KeyRPressedEvent = script.Parent.KeyRPressed
local CanAttack = true
local SpecialActivated = false
script.Parent.Equipped:connect(function()
local Equip = script.Parent.Parent.Humanoid:LoadAnimation(script.Equip)
local Idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle)
local SwingAttack = script.Parent.Parent.Humanoid:LoadAnimation(script.SwingAttack)
local SideAttack = script.Parent.Parent.Humanoid:LoadAnimation(script.SideAttack)
local SideAttack2 = script.Parent.Parent.Humanoid:LoadAnimation(script.SideAttack2)
local Choke = script.Parent.Parent.Humanoid:LoadAnimation(script.Choke)
local Trail = script.Parent.MainTrail.Trail
Trail.Attachment0 = Trail.Parent.Attachment
Trail.Attachment1 = Trail.Parent.Parent.Trail.Attachment
Equip:Play()
wait(1)
Idle:Play()
local function OnKeyQPressedFired(Player)
if SpecialActivated == false then
local MainPlayer = script.Parent.Parent:WaitForChild("HumanoidRootPart")
for _, TargetPlayer in pairs(game.Players:GetPlayers()) do
if TargetPlayer then
local TargetCharacter = TargetPlayer.Character
local Magnitude = (MainPlayer.Position - TargetCharacter:WaitForChild("HumanoidRootPart").Position).magnitude
if Magnitude < 25 and Magnitude > 0 then
SpecialActivated = true
Choke:Play()
MainPlayer.Parent.Humanoid.WalkSpeed = 0
MainPlayer.Parent.Humanoid.JumpPower = 0
for _, Parts in pairs(script.Parent:GetChildren()) do
if Parts and Parts:IsA("Part") or Parts:IsA("UnionOperation") or Parts:IsA("WedgePart") then
Parts.Transparency = 1
end
end
local Choking = TargetCharacter.Humanoid:LoadAnimation(script.Choking)
Choking:Play()
TargetCharacter.Humanoid.WalkSpeed = 0
TargetCharacter.Humanoid.JumpPower = 0
Choking.Stopped:connect(function()
TargetCharacter.Humanoid.WalkSpeed = 16
TargetCharacter.Humanoid.JumpPower = 50
TargetCharacter.Humanoid:TakeDamage(100)
end)
Choke.Stoppped:connect(function()
SpecialActivated = false
for _, Parts in pairs(script.Parent:GetChildren()) do
if Parts and Parts:IsA("Part") or Parts:IsA("UnionOperation") or Parts:IsA("WedgePart") then
Parts.Transparency = 0
MainPlayer.Parent.Humanoid.WalkSpeed = 16
MainPlayer.Parent.Humanoid.JumpPower = 50
if Parts.Name == "Handle" then
Parts.Transparency = 1
end
end
end
end)
end
end
end
end
end
local function OnKeyEPressedFired(Player)
if SpecialActivated == false then
SpecialActivated = true
local MainPlayer = script.Parent.Parent:WaitForChild("HumanoidRootPart")
local BlurEffect = Instance.new("BlurEffect")
MainPlayer.Parent:WaitForChild("Humanoid").WalkSpeed = 24
BlurEffect.Size = 5
BlurEffect.Enabled = true
BlurEffect.Parent = game.Workspace.CurrentCamera
wait(5)
MainPlayer.Parent:WaitForChild("Humanoid").WalkSpeed = 16
BlurEffect.Size = 0
BlurEffect.Enabled = false
SpecialActivated = false
end
end
local function OnKeyRPressedFired(Player)
local MainPlayer = script.Parent.Parent:WaitForChild("HumanoidRootPart")
MainPlayer.Parent:WaitForChild("Humanoid").MaxHealth = 600
MainPlayer.Parent:WaitForChild("Humanoid").Health = 600
wait(10)
MainPlayer.Parent:WaitForChild("Humanoid").MaxHealth = 450
MainPlayer.Parent:WaitForChild("Humanoid").MaxHealth = 450
end
KeyQPressedEvent.OnServerEvent:connect(OnKeyQPressedFired)
KeyEPressedEvent.OnServerEvent:connect(OnKeyEPressedFired)
KeyRPressedEvent.OnServerEvent:connect(OnKeyRPressedFired)
script.Parent.Activated:connect(function()
local Equip = script.Parent.Parent.Humanoid:LoadAnimation(script.Equip)
local Idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle)
local SwingAttack = script.Parent.Parent.Humanoid:LoadAnimation(script.SwingAttack)
local SideAttack = script.Parent.Parent.Humanoid:LoadAnimation(script.SideAttack)
local SideAttack2 = script.Parent.Parent.Humanoid:LoadAnimation(script.SideAttack2)
if CanAttack == true then
local RandomAttack = math.random(1,3)
if RandomAttack == 1 then
SwingAttack:Play()
Idle:Stop()
CanAttack = false
script.Parent.CanDamage.Value = true
wait(1) -- Animation Length
SwingAttack:Stop()
Idle:Play()
CanAttack = true
elseif RandomAttack == 2 then
SideAttack:Play()
Idle:Stop()
CanAttack = false
script.Parent.CanDamage.Value = true
wait(1) -- Animation Length
SideAttack:Stop()
Idle:Play()
CanAttack = true
elseif RandomAttack == 3 then
SideAttack2:Play()
Idle:Stop()
CanAttack = false
script.Parent.CanDamage.Value = true
wait(1) -- Animation Length
SideAttack2:Stop()
Idle:Play()
CanAttack = true
end
end
end)
Thank you for your time hopefully someone can figure it out :)

1 comment
is line 56 suppose to be only "end"