[v1.1] Easily create a floating gui with this module! (Beginner friendly)

Were you ever playing games like PHIGHTING! [ALPHA] or Jujutsu Infinite and really liked their GUI because it was uniquely floating? Have you tried recreating their unique GUI but failed?

Well this module is an easy way to implement a uniquely floating GUI into your game!

Examples:

Creating a floating gui.

local FloatingGui = require(game.ReplicatedStorage:WaitForChild('FloatingGui'))

local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild('PlayerGui')
local ScreenGui = PlayerGui:WaitForChild('ScreenGui')

local Gui = FloatingGui.new(ScreenGui, {
    -- These are all the options you can provide:

	Distance = 0.2, -- Distance in studs in between the camera and the floating gui.
	Speed = 0.9, -- Speed from 0 to 1 that represents the follow speed of the floating gui.
	Angle = 3, -- Rotation of the floating gui in degrees.
	Offset = Vector2.new(0, 0) -- Offset of the floating gui based on scale.
})


Changing an existing floating gui after two seconds.

local FloatingGui = require(game.ReplicatedStorage:WaitForChild('FloatingGui'))

local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild('PlayerGui')
local ScreenGui = PlayerGui:WaitForChild('ScreenGui')

local Gui = FloatingGui.new(ScreenGui, {
	Distance = 1, -- Distance in studs in between the camera and the floating gui.
})

wait(2)

Gui:Change({
	Distance = 0.2, -- Distance in studs in between the camera and the floating gui.
	Speed = 0.9, -- Speed from 0 to 1 that represents the follow speed of the floating gui.
	Angle = 3, -- Rotation of the floating gui in degrees.
})


Removing an existing floating gui after two seconds.

local FloatingGui = require(game.ReplicatedStorage:WaitForChild('FloatingGui'))

local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild('PlayerGui')
local ScreenGui = PlayerGui:WaitForChild('ScreenGui')

local Gui = FloatingGui.new(ScreenGui)

wait(2)

Gui:Remove()


Enabling and disabling a floating gui.

local FloatingGui = require(game.ReplicatedStorage:WaitForChild('FloatingGui'))

local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild('PlayerGui')
local ScreenGui = PlayerGui:WaitForChild('ScreenGui')

local Gui = FloatingGui.new(ScreenGui)

Gui:Enable(false)

wait(2)

Gui:Enable(true) -- Gui:Enable(true) or Gui:Enable()


Creating multiple floating guis.

local FloatingGui = require(game.ReplicatedStorage:WaitForChild('FloatingGui'))

local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild('PlayerGui')
local ScreenGui = PlayerGui:WaitForChild('ScreenGui')
local ScreenGui2 = PlayerGui:WaitForChild('ScreenGui2')

local Gui1 = FloatingGui.new(ScreenGui, {
	Distance = 0.2, -- Distance in studs in between the camera and the floating gui.
	Speed = 0.9, -- Speed from 0 to 1 that represents the follow speed of the floating gui.
	Angle = 3, -- Rotation of the floating gui in degrees.
	Offset = Vector2.new(0, 0) -- Offset of the floating gui based on scale.
})

local Gui2 = FloatingGui.new(ScreenGui2, {
	Distance = 0.2, -- Distance in studs in between the camera and the floating gui.
	Speed = 0.9, -- Speed from 0 to 1 that represents the follow speed of the floating gui.
	Angle = -3, -- Rotation of the floating gui in degrees.
	Offset = Vector2.new(0, 0) -- Offset of the floating gui based on scale.
})


A real example.


My Explorer:
image


My health bar and stamina bar:



My code (StarterGui.FloatingGui):

local FloatingGui = require(game.ReplicatedStorage:WaitForChild('FloatingGui'))

local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild('PlayerGui')
local HealthGui = PlayerGui:WaitForChild('HealthGui')
local StaminaGui = PlayerGui:WaitForChild('StaminaGui')

local Gui1 = FloatingGui.new(HealthGui, {
	Distance = 0.2, -- Distance in studs in between the camera and the floating gui.
	Speed = 0.9, -- Speed from 0 to 1 that represents the follow speed of the floating gui.
	Angle = 3, -- Rotation of the floating gui in degrees.
	Offset = Vector2.new(0, 0) -- Offset of the floating gui based on scale.
})

local Gui2 = FloatingGui.new(StaminaGui, {
	Distance = 0.2, -- Distance in studs in between the camera and the floating gui.
	Speed = 0.9, -- Speed from 0 to 1 that represents the follow speed of the floating gui.
	Angle = -3, -- Rotation of the floating gui in degrees.
	Offset = Vector2.new(0, 0) -- Offset of the floating gui based on scale.
})


Result:


Exceptions.

local FloatingGui = require(game.ReplicatedStorage:WaitForChild('FloatingGui'))

local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild('PlayerGui')
local ScreenGui = PlayerGui:WaitForChild('ScreenGui')

-- When no options are provided the floating gui will be given default options.
local Gui = FloatingGui.new(ScreenGui)


Source.

Link: https://create.roblox.com/store/asset/17170508056/FloatingGui?tab=description

(Please credit it me whenever you use it in your game, thanks!)
(Also would appreciate feedback or ideas for new features, you can message me on discord @lukanker.)

19 Likes

you forgot to add the module link to the post

2 Likes

Accidentally posted it when I wasn’t finished, but it’s all good now. Let me know if you come across any problems, because I made this module pretty quickly.

1 Like

Looks great bro, you cooked!! :fire: :fire:

2 Likes

seems like its private?
Screenshot 2024-04-16 191144

3 Likes

I kid you not, I have been searching the internet for ages looking for a tutorial for this. You are the best!

3 Likes

Sorry! The model should be public now.

2 Likes

Version 1.1 changes if anyone is interested:

  • (Bug) The adornee of the SurfaceGui doesn’t stay anymore when the SurfaceGui is destroyed.
  • The ScreenGui used for the FloatingGui will be converted to the SurfaceGui and this SurfaceGui will have the same parent as the ScreenGui, in turn the ScreenGui’s parent becomes ReplicatedFirst (as temporary parent, for whenever the user decides to :Remove the FloatingGui, which will make the ScreenGui have its original parent again)
  • Any children inside the ScreenGui will be parented to the SurfaceGui. (children won’t be cloned over anymore, to avoid scripts running twice)
  • After calling :Remove on the FloatingGui, the ScreenGui will be parented back to its original parent, and all its original children will be parented back to the ScreenGui.

Is there a way to add this floating mechanic to existing screenguis?