속도 제한이 있는 텍스트 입력

*이 콘텐츠는 AI(베타)를 사용해 번역되었으며, 오류가 있을 수 있습니다. 이 페이지를 영어로 보려면 여기를 클릭하세요.

이 예제에서는 플레이어가 커뮤니티 게시판에 메모를 게시할 수 있는 텍스트 입력 필드에 1분 속도 제한을 구현하는 방법을 보여줍니다.

다음 코드를 ServerScriptServiceScript에 추가하세요:

Server

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- 통신을 위한 RemoteEvent 생성
local postNoteEvent = Instance.new("RemoteEvent")
postNoteEvent.Name = "PostNoteEvent"
postNoteEvent.Parent = ReplicatedStorage
-- 플레이어당 분당 한 개의 메모 속도 제한
local COOLDOWN_TIME = 60 -- 초 단위 시간
local lastPostTime = {}
local function canPlayerPost(player)
local userId = player.UserId
local currentTime = tick()
if lastPostTime[userId] then
local timeSinceLastPost = currentTime - lastPostTime[userId]
if timeSinceLastPost < COOLDOWN_TIME then
return false, COOLDOWN_TIME - timeSinceLastPost
end
end
return true, 0
end
-- 속도 제한과 텍스트 필터링을 통한 게시 요청 처리
postNoteEvent.OnServerEvent:Connect(function(player, noteData)
local canPost, cooldown = canPlayerPost(player)
if not canPost then
postNoteEvent:FireClient(player, "cooldown", math.ceil(cooldown))
return
end
-- 공개적으로 공유되는 모든 텍스트는 텍스트 필터를 통과해야 함
local filterResult = getFilterResult(noteData.text, player.UserId)
if filterResult then
local success, filteredText = pcall(function()
return filterResult:GetNonChatStringForBroadcastAsync()
end)
if success then
-- 메모 생성
local note = {
text = filteredText
}
-- 마지막 게시 시간 업데이트
lastPostTime[player.UserId] = tick()
-- 성공 응답 전송
postNoteEvent:FireClient(player, "success", note)
-- 모든 플레이어에게 새로운 메모 방송
postNoteEvent:FireAllClients("newNote", note)
else
warn("텍스트 필터링 중 오류 발생!")
end
end)
-- 플레이어가 나갈 때 정리
Players.PlayerRemoving:Connect(function(player)
lastPostTime[player.UserId] = nil
end)
©2026 Roblox Corporation. Roblox 및 Roblox 로고, 'Powering Imagination'은 미국 및 기타 국가 내 당사의 등록 및 미등록 상표입니다.