Hello Developers! Recently, I made a roleplay name system, and realised that that was the bad comment zone. You don’t wanna know how I know this had no filter …Jk, I spammed random letters. Back to the subject; does anyone know if they could edit this script to my needs. Thanks:
local serverstorage = game:GetService("ServerStorage")
local gui = serverstorage:WaitForChild("BillboardGui")
game.ReplicatedStorage.RolePlayEvent.OnServerEvent:Connect(function(player, text)
local char = player.Character or player.CharacterAdded:Wait()
local head = char.Head
local clonegui = gui:Clone()
clonegui.Name = "RolePlayName"
clonegui.TextLabel.Text = text
clonegui.Parent = head
if head.RolePlayName and head.RolePlayName ~= clonegui then
head.RolePlayName:Destroy()
end
end)
Your game will be taken down if you don’t filter user input properly, this function should work
function filterString(player: Instance, str: string): any
if typeof(str) == "string" then
local filteredString
local suc, err = pcall(function()
filteredString = game:GetService("Chat"):FilterStringForBroadcast(str, player)
end)
if err then
return nil
end
return filteredString
end
end
Sure: (the filter doesn’t work in studio so it wont get filtered)
local serverstorage = game:GetService("ServerStorage")
local gui = serverstorage:WaitForChild("BillboardGui")
local function filterString(player: Instance, str: string)
if typeof(str) == "string" then
local filteredString
local suc = pcall(function()
filteredString = game:GetService("Chat"):FilterStringForBroadcast(str, player)
end)
if not suc then
return nil
end
return filteredString
end
end
game.ReplicatedStorage.RolePlayEvent.OnServerEvent:Connect(function(player, text)
local char = player.Character or player.CharacterAdded:Wait()
local head = char.Head
local filteredString = filterString(player, text)
if filteredString ~= nil then
local clonegui = gui:Clone()
clonegui.Name = "RolePlayName"
clonegui.TextLabel.Text = filteredString
clonegui.Parent = head
if head.RolePlayName and head.RolePlayName ~= clonegui then
head.RolePlayName:Destroy()
end
else
-- failed to filter so nothing happens
end
end)