How to make something like this

Greetings devforum.

I am making a game like De pride isle, although when it comes to the staffing stuff, I am experiencing some issues, that include making a message system for it, basically when you click the send button, it will send it to a scrolling frame, if there is already messages above, they will move down & eventually delete hope that makes sense if you need more of a showcase please let me know and I’ll provide you a video on what I need!

Best regards,
sam

3 Likes

Video:

1 Like

You can use a UIListLayout | Roblox Creator Documentation in the scrollingframe.

But how would I make it move down, then once a certain amount of messages reach they start to disappear?

You can do something like this when the player sends a message:

local ScrollingFrame = script.Parent
local MaxMessages = 5

local MessagesCount = 0
for _, object in pairs(ScrollingFrame:GetChildren()) do
	if object:IsA("GuiObject") then
		MessagesCount += 1
	end
end
if MessagesCount >= MaxMessages then
	local LastMessage
	for _, object in ipairs(ScrollingFrame:GetChildren()) do
		if object:IsA("GuiObject") then
			LastMessage = object
			break
		end
	end
	if LastMessage then
		LastMessage:Destroy()
	end
end

And to make the messages move down, set the VerticalAlignment to Bottom in the UIListLayout

I made a quick script, but nothings appearing.


local p = game.Players.LocalPlayer

MessageEvent.Event:Connect(function(plr)
	if script.Parent.SCMain.TextBox.Text == "" or script.Parent.SCMain.TextBox.Text == " " then
		warn("You need a message to send")
	else
		local Template = script.Parent.SCMain.ChatScroller.Template:Clone()
		Template.TextMain.Text = script.Parent.SCMain.TextBox.Text
		Template.IconBorder.TitleBorder.Title.TextLabel.Text = p.Name
		Template.IconBorder.Icon.Image = "https://www.roblox.com/headshot-thumbnail/image?userId=".. p.UserId .."&width=420&height=420&format=png"
		Template.Visible = true
	end
end)

Alrighty, let me test that script thank you!

Remember to change the parent of the template to the scrollingframe when you clone it.

If you want the message to appear on the screen of all players, use a RemoteEvent | Roblox Creator Documentation and you can use TextService | Roblox Creator Documentation to filter the text

Still having issues, here’s the script:

Local script:




--															  VARIABLES																	--
local RS = game:GetService("ReplicatedStorage")
local SS = game:GetService("ServerScriptService")
local MessageEvent = script.Parent.MessageEvent
local p = game.Players.LocalPlayer

local MaxMessages = 8
local NotificationSound = script.Parent.Notif

local ScrollingFrame = script.Parent.SCMain.ChatScroller
--															 	SCRIPT																	--

local MessagesCount = 0


MessageEvent.Event:Connect(function()
	if script.Parent.SCMain.TextBox.Text == "" or script.Parent.SCMain.TextBox.Text == " " then
		warn("You need a message to send")
	else
		local Template = script.Parent.SCMain.ChatScroller.Template
		Template:Clone()
		Template.Parent = script.Parent.SCMain.ChatScroller
		Template.TextMain.Text = script.Parent.SCMain.TextBox.Text
		Template.IconBorder.TitleBorder.Title.TextLabel.Text = p.Name
		Template.IconBorder.Icon.Image = "https://www.roblox.com/headshot-thumbnail/image?userId=".. p.UserId .."&width=420&height=420&format=png"
		Template.Visible = true
		game.ReplicatedStorage.Events.Messaging:FireServer(script.Parent.SCMain.TextBox.Text)
	end
end)

for _, object in pairs(ScrollingFrame:GetChildren()) do
	if object:IsA("GuiObject") then
		MessagesCount += 1
	end
end
if MessagesCount >= MaxMessages then
	local LastMessage = ScrollingFrame:GetChildren()[#ScrollingFrame:GetChildren()]
	if LastMessage:IsA("GuiObject") then
		LastMessage:Destroy()
	end
end

script.Parent.SCMain.ImageButton.MouseButton1Click:Connect(function()
	MessageEvent:Fire()
end)


Server-script:


game.ReplicatedStorage.Events.Messaging.OnServerEvent:Connect(function(plr, context)
	if context == nil then
		print("No message")
	else
		print(context .. plr.Name .. plr.UserId .. " - Found")
	end
end)

It prints the following,
image
Meaning that it’s firing but not appearing for other players, I’m not sure where I went wrong my head’s really confused today and probably did something wrong, so yeah, lol i apologize.

Use RemoteEvent | Roblox Creator Documentation

I think this should work.

LocalScript:




--															  VARIABLES																	--
local RS = game:GetService("ReplicatedStorage")
local SS = game:GetService("ServerScriptService")
local MessageEvent = script.Parent.MessageEvent
local p = game.Players.LocalPlayer

local MaxMessages = 8
local NotificationSound = script.Parent.Notif

local ScrollingFrame = script.Parent.SCMain.ChatScroller
--															 	SCRIPT																	--


game.ReplicatedStorage.Events.Messaging.OnClientEvent:Connect(function(playerFrom, message)
	local MessagesCount = 0
	for _, object in pairs(ScrollingFrame:GetChildren()) do
		if object:IsA("GuiObject") then
			MessagesCount += 1
		end
	end
	if MessagesCount >= MaxMessages then
		local LastMessage
		for _, object in ipairs(ScrollingFrame:GetChildren()) do
			if object:IsA("GuiObject") then
				LastMessage = object
				break
			end
		end
		if LastMessage then
			LastMessage:Destroy()
		end
	end
		local Template = script.Parent.SCMain.ChatScroller.Template:Clone()
		Template.Parent = script.Parent.SCMain.ChatScroller
		Template.TextMain.Text = message
		Template.IconBorder.TitleBorder.Title.TextLabel.Text = playerFrom.Name
		Template.IconBorder.Icon.Image = "https://www.roblox.com/headshot-thumbnail/image?userId=".. playerFrom.UserId .."&width=420&height=420&format=png"
		Template.Visible = true
end)

script.Parent.SCMain.ImageButton.MouseButton1Click:Connect(function()
	if script.Parent.SCMain.TextBox.Text == "" or script.Parent.SCMain.TextBox.Text == " " then
		warn("You need a message to send")
	else
		game.ReplicatedStorage.Events.Messaging:FireServer(script.Parent.SCMain.TextBox.Text)
	end
end)

Server script:

local TextService = game:GetService("TextService")

game.ReplicatedStorage.Events.Messaging.OnServerEvent:Connect(function(plr, context)
	if context == nil then
		print("No message")
	else
		local success, result = pcall(function()
			return TextService:FilterStringAsync(context, plr.UserId)
		end)
		if success then
			local filteredMessage = result:GetNonChatStringForBroadcastAsync()
			game.ReplicatedStorage.Events.Messaging:FireAllClients(plr, filteredMessage)
		end
	end
end)
1 Like

Hey it works, but the message aka the template frame isn’t cloning itself and is just sticking to 1 version of its-self.

I corrected it, does it work now?

Testing, thank you for all the help!

It now works but now the messages aint deleting once it reaches the max limit, lol.

Can you take a screenshot of the explorer and send it here?

Where, in-game or out of the game, like whern it’s running or?
image
When it’s running and I’m pressing.

Does it work if you put the code like this?




--															  VARIABLES																	--
local RS = game:GetService("ReplicatedStorage")
local SS = game:GetService("ServerScriptService")
local MessageEvent = script.Parent.MessageEvent
local p = game.Players.LocalPlayer

local MaxMessages = 8
local NotificationSound = script.Parent.Notif

local ScrollingFrame = script.Parent.SCMain.ChatScroller
--															 	SCRIPT																	--


game.ReplicatedStorage.Events.Messaging.OnClientEvent:Connect(function(playerFrom, message)
	local Template = script.Parent.SCMain.ChatScroller.Template:Clone()
	Template.Parent = script.Parent.SCMain.ChatScroller
	Template.TextMain.Text = message
	Template.IconBorder.TitleBorder.Title.TextLabel.Text = playerFrom.Name
	Template.IconBorder.Icon.Image = "https://www.roblox.com/headshot-thumbnail/image?userId=".. playerFrom.UserId .."&width=420&height=420&format=png"
	Template.Visible = true
	local MessagesCount = 0
	for _, object in pairs(ScrollingFrame:GetChildren()) do
		if object:IsA("Frame") then
			MessagesCount += 1
		end
	end
	if MessagesCount >= MaxMessages then
		local LastMessage
		for _, object in ipairs(ScrollingFrame:GetChildren()) do
			if object:IsA("Frame") then
				LastMessage = object
				break
			end
		end
		if LastMessage then
			LastMessage:Destroy()
		end
	end
end)

script.Parent.SCMain.ImageButton.MouseButton1Click:Connect(function()
	if script.Parent.SCMain.TextBox.Text == "" or script.Parent.SCMain.TextBox.Text == " " then
		warn("You need a message to send")
	else
		game.ReplicatedStorage.Events.Messaging:FireServer(script.Parent.SCMain.TextBox.Text)
	end
end)

Nope, still the same issue :confused:

This should fix the problem:




--															  VARIABLES																	--
local RS = game:GetService("ReplicatedStorage")
local SS = game:GetService("ServerScriptService")
local MessageEvent = script.Parent.MessageEvent
local p = game.Players.LocalPlayer

local MaxMessages = 8
local MessagesTable = {}
local NotificationSound = script.Parent.Notif

local ScrollingFrame = script.Parent.SCMain.ChatScroller
--		SCRIPT																	--

ScrollingFrame.ChildAdded:Connect(function(Object)
	if Object:IsA("Frame") then
		table.insert(MessagesTable, Object)
	end
end)


game.ReplicatedStorage.Events.Messaging.OnClientEvent:Connect(function(playerFrom, message)
	local Template = script.Parent.SCMain.ChatScroller.Template:Clone()
	Template.Parent = script.Parent.SCMain.ChatScroller
	Template.TextMain.Text = message
	Template.IconBorder.TitleBorder.Title.TextLabel.Text = playerFrom.Name
	Template.IconBorder.Icon.Image = "https://www.roblox.com/headshot-thumbnail/image?userId=".. playerFrom.UserId .."&width=420&height=420&format=png"
	Template.Visible = true
	local MessagesCount = 0
	for _, object in pairs(ScrollingFrame:GetChildren()) do
		if object:IsA("Frame") then
			MessagesCount += 1
		end
	end
	if MessagesCount >= MaxMessages then
		if #MessagesTable > 0 then
			local LastMessage = MessagesTable[1]
			if LastMessage then
				LastMessage:Destroy()
				table.remove(MessagesTable, 1)
			end
		end
	end
end)

script.Parent.SCMain.ImageButton.MouseButton1Click:Connect(function()
	if script.Parent.SCMain.TextBox.Text == "" or script.Parent.SCMain.TextBox.Text == " " then
		warn("You need a message to send")
	else
		game.ReplicatedStorage.Events.Messaging:FireServer(script.Parent.SCMain.TextBox.Text)
	end
end)
1 Like

Still nope, doesn’t work. :confused: