So I am writing an admin script and I have a module script responsible for creating the “hints” (aka bar text at the top of the screen) which I can then require in order to create the hint, I do that with the following code:
local hints = {}
local TextService = game:GetService("TextService")
local PrevHint = nil
function hints.NewHint(player, text, serverMessage)
local maxHints = 5
if player ~= nil and text ~= "" and #player.PlayerGui:FindFirstChild("CAHints"):GetChildren() <= 5 then
local Hint_2 = Instance.new("TextLabel")
Hint_2.Name = "PrevHint"
Hint_2.Parent = player.PlayerGui:FindFirstChild("CAHints")
Hint_2.BackgroundColor3 = Color3.fromRGB(31, 31, 31)
Hint_2.BackgroundTransparency = 1.000
Hint_2.Size = UDim2.new(1, 0, 0.0483680554, 0)
Hint_2.Font = Enum.Font.GothamBold
if serverMessage == false then
local isSuccessful, textFilterResult = pcall(TextService.FilterStringAsync, TextService, text, player.UserId, Enum.TextFilterContext.PublicChat)
if isSuccessful then
local isSuccessful, str = pcall(textFilterResult.GetChatForUserAsync, textFilterResult, player.UserId)
if isSuccessful then
Hint_2.Text = str
Hint_2.TextColor3 = Color3.fromRGB(255, 255, 255)
Hint_2.TextScaled = true
Hint_2.TextSize = 14.000
Hint_2.TextWrapped = true
Hint_2.Position = UDim2.new(0, 0, -0.1, 0)
Hint_2.BackgroundTransparency = 0.4
local curHint = PrevHint
if PrevHint ~= nil then
local position = UDim2.new(0, 0, PrevHint.Position.Y.Scale + 0.048, 0)
Hint_2:TweenPosition(position,"Out","Sine",0.3,false)
PrevHint = Hint_2
else
Hint_2:TweenPosition(UDim2.new(0, 0, 0, 0),"Out","Sine",0.3,false)
PrevHint = Hint_2
end
wait(string.len(Hint_2.Text) * 0.05 + 0.4)
local position = UDim2.new(1.1 , 0, Hint_2.Position.Y.Scale, 0)
Hint_2:TweenPosition(position,"Out","Sine",0.3,false)
wait(.301)
Hint_2:Destroy()
PrevHint = nil
end
end
else
Hint_2.Text = text
Hint_2.TextColor3 = Color3.fromRGB(255, 255, 255)
Hint_2.TextScaled = true
Hint_2.TextSize = 14.000
Hint_2.TextWrapped = true
Hint_2.Position = UDim2.new(0, 0, -0.1, 0)
Hint_2.BackgroundTransparency = 0.4
local curHint = prevHint
if prevHint ~= nil then
local position = UDim2.new(0, 0, prevHint.Position.Y.Scale + 0.048, 0)
Hint_2:TweenPosition(position,"Out","Sine",0.3,false)
prevHint = Hint_2
else
Hint_2:TweenPosition(UDim2.new(0, 0, 0, 0),"Out","Sine",0.3,false)
prevHint = Hint_2
end
wait(string.len(Hint_2.Text) * 0.05 + 0.4)
local position = UDim2.new(1.1 , 0, Hint_2.Position.Y.Scale, 0)
Hint_2:TweenPosition(position,"Out","Sine",0.3,false)
wait(.301)
Hint_2:Destroy()
prevHint = nil
end
end
end
return hints
So the player is the player whose PlayerGui we insert the hint into. The text is the message we are displaying. And serverMessage is a boolean value passed through which tells the script whether or not we need to apply the Roblox chat filter, because if it is a client message using the command :h for example which would allow the player to create a hint, we would need to filter it, but server messages are already filtered so it is unnecessary.
So currently, I have a system which detects if there is already a hint in the PlayerGui, we tween the current hint under the previous hint, that works for the most part but I want a smart system which automatically updates the position of hints so if one tweens away, the rest underneath it slot up a place. I also want to make it so if it exceeds the limit (5) then the hint at the top will automatically tween off to make space for a potential 6th.
I am not asking for an entire script, I just want to know if these are minor changes or not and if it is possible with my current system.