How do datastore plugins work?

Hey, so I am wondering how datastore plugins work because I been working on a plugin that uses the new roblox ban API and I got this error:
BanAsync() can only be called on the server

It is a server script
image

Script:

local config: BanConfigType = {
		UserIds = {2758548757},
		Duration = 500,
		DisplayReason = 'test',
		PrivateReason = 'test2',
		ExcludeAltAccounts = false,
		ApplyToUniverse = true
	}

	local success, err = pcall(function()
		return Players:BanAsync(config)
	end)

if success then
    print(success
else
  warn(err)
end

So im wondering, if plugins dont have access to the server, then how do datastore plugins work?

1 Like

I believe plugins are considered as both server and client when run. If you call RunService:IsClient() and RunService:IsServer(), they both return true.

So a plugin should have access to most server services, or at the very least DataStoreService. I’m not sure why there’s an exception for this function. Maybe they’re enforcing that it only be called in an actual server runtime environment?

2 Likes

That would be a good choice, imagine if any bad plugin could ban the developer itself or anyone else.


I don’t know if it’s gonna work but try setting the plugin-script’s RunContext to Server? Or Plugin?

2 Likes

Hey, I set the RunContext to Server but it still wouldn’t work.

Plugin isnt an option, there is only: Legacy, Client and Server

1 Like