A comment section for your game

a comment section for your game
see what players have to comment
you need to set it up once your ready you can comment
fire SeeComments to open

comments.rbxm (18.5 KB)
set up

the script goes in serverscriptservice
all remotes goes in replicated storage
the example frame goes in replicated storage
the screen gui goes in startergui
it requires datastore service

if you do it right it works


-- script that should go in serverscriptservice
local DataStoreService = game:GetService("DataStoreService")
local CommentsStore = DataStoreService:GetDataStore('Commentsdata')

game.ReplicatedStorage.RemoteCommentFunction.OnServerInvoke = function(player,CommentText)
    -- this RemoteFunction is for the processing of DataStoreService,TextService 
	local TextService = game:GetService("TextService")
	-- look for errors-- here are the requirements
    -- do return if the comment is invalid for you
	local checkText = string.lower(CommentText)
	if checkText == '' or checkText == nil then
		return 'comment cant be empty'
	end
	
	local cant = {['i love your game'] = true,['your the best dev'] = true,['your the best developer'] = true,['i love you'] = true}
	if cant[checkText] then
		return 'i added this to help this game become better' 
	end
	
	if string.len(checkText) < 7 then
		return 'enter at least 7 characters '.. string.upper('and dont spam')
	end
	
	if string.find(checkText,'dislike') or  string.find(checkText,'hate')  then
		player:Kick('invalid comment')
		return 'just cant'
	end
	-- here do we the filter
	local s,e = pcall(function()
		return TextService:FilterStringAsync(CommentText,player.UserId,Enum.TextFilterContext.PublicChat)
	end)
	
	if s then
		local Text = e:GetNonChatStringForBroadcastAsync ( )
		if not string.find(Text,'#') then
			local Budget=DataStoreService:GetRequestBudgetForRequestType(Enum.DataStoreRequestType.UpdateAsync)
			if Budget >40 then
				local ss,ee = pcall(function()
					CommentsStore:UpdateAsync('comments',function(oldValue)
						if oldValue then
							table.insert(oldValue,1,{CommentText = Text,Player = player.UserId,OsTime = os.time()})
						else
							oldValue = {}
							table.insert(oldValue,1,{CommentText = Text,Player = player.UserId,OsTime = os.time()})
						end
						game.ReplicatedStorage.UpdateComments:FireAllClients({CommentText = Text,Player = player.UserId,OsTime = os.time()})
						return oldValue--newValue
					end)
				end)
				if ss then
					return 'Success'..' (your comment has been success fully processed)'
				else
					return 'DataStore Faild'..' (Try Again)'
				end
			else
				return 'DataStoreBudget too low'..' wait and then (Try Again)'
			end
		else
			return 'text contains #'..' (Try Again) with a diffrent text'
		end
	else
		return 'filtering failed'..' (Try Again)'
	end	
end
local run = game:GetService("RunService")
function UpdateComments()
	if run:IsStudio() then
		return
	end
	if DataStoreService:GetRequestBudgetForRequestType(Enum.DataStoreRequestType.GetAsync)>55 then
		local data = CommentsStore:GetAsync('comments')
		game.ReplicatedStorage.Delete:FireAllClients()
		for i,v in ipairs(data or {}) do
			pcall(function()
				game.ReplicatedStorage.UpdateComments:FireAllClients(v)
			end)
			wait(.3)
		end
		game.ReplicatedStorage.updateSuccessfully:FireAllClients()
	else
		print('DataStoreBudget is too low')
	end
end
delay(10,UpdateComments)

local Devs = {480482151}

while wait(60) do
	UpdateComments()
end
--local script that should stay where it is
local Change = function(bool)
	script.Parent.Visible = bool
end
game.ReplicatedStorage.SeeComments.OnClientEvent:Connect(function()
	Change(true)
end)
script.Parent.Close.MouseButton1Click:Connect(function()
	Change(false)
end)
local debounce = false
script.Parent.PageLeft.comment.MouseButton1Click:Connect(function()
	local write = function(Text)
		script.Parent.PageRight.CommentInfo.Text = Text
	end
	if debounce then
		write('wait until your comment is processed')
	end
	debounce =true
	write('your comment is being processed')
	local result = game.ReplicatedStorage.RemoteCommentFunction:InvokeServer(script.Parent.PageLeft.TextBox.Text)
	script.Parent.PageLeft.TextBox.Text = ''
	write(result)
	wait(14)
	write('enter a comment')
	debounce = false
end)
MarketplaceService=game:GetService("MarketplaceService")
game.ReplicatedStorage.UpdateComments.OnClientEvent:Connect(function(data)
	print('load Comments')
	local ExampleComment = game.ReplicatedStorage.ExampleComment:Clone()
	local user = game:GetService("UserService")
	local result = {}
	--
	local Comment = ExampleComment:WaitForChild('Comment')
	local DisplayName = Comment:WaitForChild('DisplayName')
	local UnixTimeSTAMP = Comment:WaitForChild('UnixTimeSTAMP')
	local UserName = Comment:WaitForChild('UserName')
	local Comment = Comment:WaitForChild('Comment')
	--
	local tableOfComments = {DisplayName,UserName,Comment,UnixTimeSTAMP}
	local UserOwnsGamePassAsync = false
	for i,v in ipairs(tableOfComments) do
		if data.Player == 480482151 then
			v.BackgroundColor3 = Color3.fromHSV(1,1,1)
		elseif UserOwnsGamePassAsync then
			v.BackgroundColor3 = Color3.fromHSV(0.161444, 1, 1)
		end
	end
	UnixTimeSTAMP.Text = tostring(data.OsTime)
	DisplayName.Text = tostring(result.DisplayName)
	UserName.Text = '@'..tostring(result.Username)
	Comment.Text = data.CommentText
	ExampleComment.Name = 'Comment'
	--dev
	ExampleComment.DeveloperConsole:WaitForChild('UserIdValue').Value = data.Player
	--
	ExampleComment.Parent=script.Parent.PageLeft.ScrollingFrame
	--dev
	wait(5)
	ExampleComment.DeveloperConsole.DevLocalScript.StartUp:Fire()
	--
end)

script.Function.OnInvoke = function(open)
	print(open)
	script.Parent.Visible = true
end
game.ReplicatedStorage.updateSuccessfully.OnClientEvent:Connect(function()
	game.StarterGui:SetCore('SendNotification',{
		Title = 'comments are updated',
		Text = 'comments are updated\n'..'you can now see the newest vertion of the comments',
		Duration = 10,
		Button1 = 'open',
		Callback = script.Function
	}
	)
end)
for i,v in ipairs(script.Parent.PageLeft.ScrollingFrame:GetChildren()) do
	if v:IsA("Frame") then
		v:Destroy()
	end
end
script.Parent.Visible = false
Change(true)

a look of the gui


how the gui should look

feel free to change text

9 Likes

Could you show the code on here also? Some people don’t have the possibility to download stuff right away (they might be on phone, school etc.) Thanks!

Edit: Thanks!

3 Likes

:joy: It’s a simple spell, but quite unbreakable.

6 Likes

you may and can add more
do return before

and after

you can add

if checkText == 'qin2007' then
	return 'you may not say Qin2007'
end

to filter Qin2007 out

in the gui that white textlabel is going to be the text you return
checkText is always lower()

Stopping people from leaving criticism on your game because it may point out something they dislike about it? I don’t agree with this. Dislike, hate? These are both valid words used to described something you think about a game. A simple, yet unnecessary spell to censor people with legitimate opinions on your game and its mechanics. This is directed at OP, not you, @lovableschoolgirl

4 Likes