How do I fix the syntax for calling this function?

I am attempting to call a function that accesses a module with the correct weapon name and then executes a specific function depending on the combat move that is being done.

local module = require(modules.AbilityModules[child:GetAttribute("ParentWeapon")])
			local ability = module:[child.Name](Anim)

The syntax of the last line is incorrect and I was wondering if there was a correct implementation of what I am trying to do. I’ve looked briefly over the devfourm, but I couldn’t find any information specifically relating to this issue. Any insight into my issue would be greatly appreciated.

1 Like

Hard to know without seeing how the function is defined! Can you share the whole module script?

here is the whole module script

local Katana = {}
local remotes = game:GetService("ReplicatedStorage").Remotes
function Katana:KatanaSlashes(Anim)
	remotes.UnequipRe:FireServer(true)
	local Cam = game.Workspace.CurrentCamera
	Cam.CameraType = Enum.CameraType.Scriptable
	Anim.AnimationId = "rbxassetid://10546676088"

	local player = game:GetService("Players").LocalPlayer

	local char = player.Character or player.CharacterAdded:Wait()
	char:WaitForChild("Humanoid").WalkSpeed = 0
	local part = char:WaitForChild("HumanoidRootPart")
	local ts = game:GetService("TweenService")

	local load = char.Humanoid:LoadAnimation(Anim):Play()
	--local CameraFrame = part.CFrame * CFrame.Angles(math.rad(0), math.rad(90), math.rad(45))
	local CameraFrame = part.CFrame + Vector3.new(0, 1, 0)
	CameraFrame = CameraFrame * CFrame.Angles(math.rad(0), math.rad(90), math.rad(10))
	CameraFrame = CameraFrame + CameraFrame.LookVector * -10
	Cam.Focus = part.CFrame
	ts:Create(Cam,TweenInfo.new(1),{CFrame = CameraFrame}):Play()
	wait(3)
	Cam.CameraType = Enum.CameraType.Custom
	char:WaitForChild("Humanoid").WalkSpeed = 16
end

return Katana

There’s really no need for your module’s function to be defined/called with a colon operator (since you’re not employing any OOP practices).

If child.Name is ‘KatanaSlashes’ then replace each colon operator with a dot operator.

function Katana.KatanaSlashes(Anim)
end
local ability = module[child.Name](Anim) --Only valid if 'child.Name' is 'KatanaSlashes'.