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!
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
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)
-- 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,
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.
-- 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)
-- 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)
-- 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)