Help with functions

Hello there, Alright so sorry if this is a dumb question im tired but while I was scripting a gun I got this error: 14:42:57.370 Players.ThoseNamesAreGood.Backpack.MA5C AR.Client:29: Expected ‘end’ (to close ‘function’ at column 32),

This is my script:

   local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Activated = false

local OnAnimation = script.Parent.Server.OnAnimation
local OnReload = script.Parent.Server.OnReload

local AR = script.Parent

local function Equipped()
	OnAnimation:FireServer()
end

local function OnActivated()
	Activated = true
	
	while wait() and Activated == true do
		AR.Server.OnShootEvent:FireServer(AR.Handle.Position, Mouse.Hit.p, .2)
	end
end

local function OnDeactivation()
	Activated = false
end


script.Parent.Activated:Connect(function(OnActivated)
script.Parent.Deactivated:Connect(function(OnDeactivation)
script.Parent.Equipped:Connect(function(Equipped)

It has something to do with the local function but I can’t figure it out…

Any help is appreciated!

3 Likes
script.Parent.Activated:Connect(OnActivated)
script.Parent.Deactivated:Connect(OnDeactivation)
script.Parent.Equipped:Connect(Equipped)

You were starting anonymous functions, the syntax is that what is above.

I detected the error:

Your code should be this:

script.Parent.Activated:Connect(OnActivated)
script.Parent.Deactivated:Connect(OnDeactivation)
script.Parent.Equipped:Connect(Equipped)

Yeah along with what @WooleyWool and @CheekySquid are saying, to call a function that’s already been made, you don’t put function before it.

don’t do this:
function(OnActivated)
do:
OnActivated()
when calling functions.

see Functions | Documentation - Roblox Creator Hub for more information.