Calling module functions by bracket names gives error

Why am I getting the following error:

Expected ‘:’ not ‘.’ calling member function LoadAsset

Code:
local model = game.GetService(game, "InsertService")['LoadAsset'](257489726)

LoadAsset is a function of GetService, it would be similar to doing:
self['funcname']('str') or self.funcname('str') or am I missing something here.

Anyway, how would I achieve what I want to do so that I can call the property of InsertService as a string, not as game:GetService("InsertService"):LoadAsset(257489726)

Any ideas why this fails?

Should it be like this maybe?

game:GetService("InsertService").LoadAsset(257489726) ?

Nvm sorry thats not right.

LoadAsset is a method, so it should be:

local service = game.GetService(game, "InsertService")
service['LoadAsset'](service, 257489726)
1 Like

Thank you, this works, just couldn’t figure out the syntax so thank you so much. My brain just does not work today! :slight_smile: :+1: