Plugin How Do I Prevent it running, when Testing a game in studio

Normally I work on solving an issue a few days before I post, but my patience is wearing thin, with my first (and most likely last) plugin I have ever made.

When in studio, and editing the map, the plugin works fine. When I go to test the game, in studio, the plugin runs, and when doing so, its causing all sorts of errors.

It is not necessary for the plugin to be executing while I am actively testing the game.

Is there any way I can code the plugin to check if we are simply in studio edit, or if we are in an actual running game inside studio, so I can prevent it from creating itself?

Thanks for any advice.

3 Likes

I suppose a simple way to do this is to check for something that wouldn’t be there in editing mode. Note that plugins start running before just about anything else in the game environment, so it’s a good idea to wait a bit before performing a check. Here are some options to choose from:

any player in game.Players
game.ServerScriptService.ChatServiceRunner
game.ReplicatedStorage.DefaultSoundEvents
game.ReplicatedStorage.DefaultChatSystemChatEvents

This is what I was thinking initially.

I was going to elaborate on how to keep it compatible with Team Create, but then I remembered that RunService:IsEdit() exists. I think IsEdit is the best way to do this.

6 Likes

Actually, there’s a similar function called IsRunMode() (or perhaps IsRunning()) that would probably be more suited for this particular use case. IsEdit() returns true even if the game instance is running.

I recall hearing that IsEdit will always return the correct value when plugins start, which is why I suggested it, but I can’t find any post mentioning it.

IsRunning should have the opposite value of IsEdit (unless you use the pause button), so they should both work just as well unless either one has problems on start. @SelDraken should test the two out and see which one works best.


Are you thinking of IsStudio()? I just tested this and it returned false in Play and Run mode.

1 Like

Oh my goodness… I thought I had tried everything in RunService to no avail, but once you said IsEdit, I kept searching the wiki for it, found it, but didn’t understand why it didn’t show up on the wiki page for RunService… then I noticed… apparently there is a little link called ‘Show Hidden Members’ :stuck_out_tongue:
This plugin has been such an uphill battle … sheesh.
Thanks for the help everyone.

2 Likes

Oh my gosh I have been doing checks for RunService:IsServer() and RunService:IsClient(), these both return true in studio, but one always returns false when in testing mode. Basically it does the same thing, but this is so much more clear. Thanks!