InteractionService | Create and manage interactions easily!

Hey! This is my first ever resource on the DevForum, so please excuse me for any mistakes.

About

This is InteractionService, a module made for creating and managing interactions. (I know there’s already something with this name, but it’s deprecated.)

Features

  • Closing interaction when player clicked outside GUI.
  • GUI follows player camera.
  • Positions around like a circle. (The buttons)

Usage

Creating interactions is actually really simple, here’s how to do it:

First, grab the model, then put it somewhere the client can access, I recommend ReplicatedStorage.

You might notice, there’s a frame inside the modulescript named “InteractionSample”, this is what your buttons will look like. You can customize it however you want, just make sure to keep the name of the frame and have the text button named “Button”.

Now, make a local script somewhere, such as in StarterGui. Also create a ScreenGui, which is where the InteractionSample will placed later.

Your local script should look like this:

local InteractionService = require("Input path to module here")
Creating an interaction

To create an interaction, use the code below.

InteractionService:CreateInteraction({
	["1"] = {
		["Text"] = "Text on button here",
		["Function"] = function()
			-- code that will run when button is clicked
		end,
	}
}, workspace.Part, Instance.new("Frame", script.Parent:WaitForChild("MainGUI")), "Input interaction name", UDim2.new(0.7, 0, 0.7, 0), 80)

The parameters are:
1: A table of all the buttons that should be created. (Table)
2: The source part of the interaction. (Part)
3: The name of the interaction, this will be used to open/delete/close the interaction. (String)
4: The size of the the frame the buttons will be placed in. (UDim2)
5: The radius of the buttons. (Number)

Opening/closing an interaction

This is very simple to use, all you gotta do is:

InteractionService:OpenInteraction("Input interaction name")

To close it, do the same thing, just replace :OpenInteraction() with :CloseInteraction().

Deleting an interaction

I’d recommend deleting your interactions when you aren’t gonna use them anymore.
To do this, use:

Interactionservice:DeleteInteraction("Input interaction name")

What this does is closing the interaction completely and you won’t be able to use it anymore. It simply cleans up the interaction and disconnects all connections.

Showcase

Code used
local InteractionService = require(Modules.InteractionService)

InteractionService:CreateInteraction({
	["1"] = {
		["Text"] = "Test",
		["Function"] = function()
			print("test")
			task.spawn(function()
				task.wait(1)
				InteractionService:OpenInteraction("Test")
			end)
		end
	},
	["2"] = {
		["Text"] = "Test2",
		["Function"] = function()
			print("test2")
			task.spawn(function()
				task.wait(1)
				InteractionService:OpenInteraction("Test")
			end)
		end
	},
	["3"] = {
		["Text"] = "Test3",
		["Function"] = function()
			print("test3")
			task.spawn(function()
				task.wait(1)
				InteractionService:OpenInteraction("Test")
			end)
		end
	}
}, workspace.Part, Instance.new("Frame", player.PlayerGui:WaitForChild("MainGUI")), "Test", UDim2.new(0.7, 0, 0.7, 0), 70)

task.wait(1)
InteractionService:OpenInteraction("Test")

Info

  • You will have to handle it opening/closing when different things happening, such as when the player walks too far away. Might change that in the future.
  • There may be bugs and issues, if so, please LMK in the replies.
  • I could have missed something in the post, LMK if so.

If you have any suggestions/feedback/need help, please LMK :wink:

Just realized I probably could’ve used BillBoardGUIs, might rewrite the module to use those instead.

18 Likes

That makes sense. I wonder if they’re doing anything similar with the chatbots.

What do you mean? I’m confused.