#Error trying to call function in table
12 messages · Page 1 of 1 (latest)
This is the function:
type AbilityType = typeof(AbilityClass.new())
local function onAbilityEvent(player, mousePos, a: AbilityType)
a:UseAbility(player)
end
base class:
local Ability = {}
function Ability.new()
local ReturningData = {}
ReturningData.Name = "AbilityBase"
ReturningData.Damage = 50
ReturningData.Cooldown = 2.5
function ReturningData:UseAbility(player)
print("Ability used ", ReturningData.Name, " by ", player)
end
return ReturningData
end
return Ability
when i try to run the function it tells me an error "Attempt to call missing method 'UseAbility' of table"
** You are now Level 1! **
Error trying to call function in table
Remove the function definition from the scope of your constructor?
(I've never worked with Lua classes in my life)
Oh wait.. I think I see what you're trying to do...
No wait. I have no clue lmfao
subclass if it helps:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local AbilityClass = require(ReplicatedStorage.AbilityType)
local A = AbilityClass.new()
A.Name = "Blah Blah"
A.Cooldown = 2
A.Damage = 50
function A:UseAbility(player)
print(player)
end
return A
hi sir