How do I call a function with command bar?

I made a function that isn’t local inside LocalScript, and I tried to call it by it’s name in the command bar but nothing happened except a returned error.

How do I call a function with command bar?

The command bar is its own environment. Put the function in a module/use a bindable event/function instead.

I put the function inside a modulescript, called it by its name, didn’t work. I thought about requiring it but then how would I require it from command bar?

You would require it ??

require(path.to.module)

You’d simply write the code like usually and then call the function. :slight_smile:

local Module = require(model) Module:Function()

Its a bit complicated to describe but the modulescript is inside startergui, which turns to playergui when the player plays the game. Do I also pass the my username through it?

Edit: Like this`

require(Players.Varsitelle.PlayerGui.ModuleScript)

You’d do it like a normal script. I made it warn(“a”) so you can see. :slight_smile:


image

1 Like

Oh so I can’t call it from client, I have to call it server side?

You can call it clinet sided. And yes you would do what you did

1 Like

The Command Bar is server based, it can access ServerStorage for example. But Client cannot. :slight_smile:

1 Like

That is not correct, the command bar can totally be used client sided. Command bar on client follows the same rules as LocalScripts.

Depends on which command bar. There is the ingame command bars SERVER and CLIENT and the studio command bar.

Then you should have clarified that you were talking about the developer console’s command bar, or OP at least. :+1:

The in-game developer console only has a command bar on the SERVER tab. Not the client. Therefore the Command Bar will always be server sided.

Edit; Since you’re doing the command from the Server and not the client.

So the command bar in-game can’t access stuff like ServerScriptService but the command bar in studio can?

The “Server” tab command bar can, since you’re doing it from the server. It’s the same command bar as the one in studio.

1 Like

Can only the owner and other permitted people access the server tab command bar while playing the game? Not the studio.

You can access the in-game server command bar if you got developer access (Access to studio)

1 Like