generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: showing DOUBLE the text?

Previous Thread :: Next Thread 
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
14 Apr 2014 08:48 PM
ok,just a warning,this IS rather simple,but its a lil long..

what its sposed to do,is filter badwords out,and replace it with "#"s

its a "ChatGui" with a custom ChatBar

it works,but whatever I type in shows up twice:

ex:

I type in:"hello world"

it shows

Player1:hello worldhello world


and I have no idea why..>_<

heres the script:

function post(name,msg)
for i,v in pairs(game.Players:GetChildren()) do
ypcall(function()
chat = game.Lighting.Chat:clone()
chat.Parent = v:WaitForChild("PlayerGui").ChatGui
chat.Text = (name..":"..msg)
game.Debris:AddItem(chat,4)
end)
end
end

function hashtag(num)
local t = ""
if num>0 then
for i=1,num do
t = t.."#"
end
end
return t
end

function Changed()
text = script.Parent.Parent.Text
plrName = script.Parent.Value
Swears = {"F","No"}
newText = {}
for i,v in pairs(Swears) do
for pos=1,string.len(text) do
if text:sub(pos,pos+string.len(v)-1) == v then
table.insert(newText,pos,hashtag(string.len(v)))
else
table.insert(newText,pos,text:sub(pos,pos))
end
end
end
text = ""
for i,v in pairs(newText) do
text = text..v
end
post(plrName,text)

end

script.Parent.Changed:connect(Changed)
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
14 Apr 2014 08:52 PM
omg,ik why>_<
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
14 Apr 2014 08:53 PM
wait..its not working..

>_<
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
14 Apr 2014 08:54 PM
ok,i changed it to this
I switched the for I,v in pairs and for I=1 loop around,but now it shows

Player1:hello worlddlrow olleh


function post(name,msg)
for i,v in pairs(game.Players:GetChildren()) do
ypcall(function()
chat = game.Lighting.Chat:clone()
chat.Parent = v:WaitForChild("PlayerGui").ChatGui
chat.Text = (name..":"..msg)
game.Debris:AddItem(chat,4)
end)
end
end
function hashtag(num)
local t = ""
if num>0 then
for i=1,num do
t = t.."#"
end
end
return t
end
function Changed()
text = script.Parent.Parent.Text
plrName = script.Parent.Value
Swears = {"F","No"}
newText = {}
for pos=1,string.len(text) do
for i,v in pairs(Swears) do
if text:sub(pos,pos+string.len(v)-1) == v then
table.insert(newText,pos,hashtag(string.len(v)))
else
table.insert(newText,pos,text:sub(pos,pos))
end
end
end
text = ""
for i,v in pairs(newText) do
text = text..v
end
post(plrName,text)

end

script.Parent.Changed:connect(Changed)
Report Abuse
AmethystKnight is not online. AmethystKnight
Joined: 08 Apr 2014
Total Posts: 36
14 Apr 2014 08:57 PM
Interesting...
I'll look at it tomorrow, for I have to rest.
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
14 Apr 2014 09:07 PM
sigh...BUMP
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
16 Apr 2014 12:11 AM
BUMP,i still cant figure this out.. >_<
Report Abuse
yurhomi10 is not online. yurhomi10
Joined: 10 Dec 2008
Total Posts: 13886
16 Apr 2014 12:19 AM
you could prob get a reply at scripting helpers
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
16 Apr 2014 12:31 AM
this IS scripting helpers,you troll..
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
16 Apr 2014 12:38 AM
My temporary answer is in the bottom part, you reuse the variable "text"


Call it something else and use it for the others below it.
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
16 Apr 2014 12:43 AM
omg,didnt even realize

should fix it XD(or at least some)
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
16 Apr 2014 12:44 AM
wait,no,thats supposed to be there >_<
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
16 Apr 2014 12:45 AM
Btw...

Don't use string.len()

It's like using math.pow


Just do #('SomeStringHers')
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
16 Apr 2014 12:47 AM
Well, island.

From what I see, I see no harm in changing what I see. It pretty much is my best guess.

This script ish too inefficient for me.
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
16 Apr 2014 01:17 AM
what its sposed to do:
set text to the chatbar text
loop thru swear words
if text:lower():sub(I,string.len(v)-1) == v:lower()--in other words,if it finds the swear..
then it converts to hashtags

function hashtag(num)

then,it adds to the table newText

table.insert(newText,etc,etc)

else,it just adds the text to the table

then,it resets text to ""
loops thru newText
sets text to text..v--so the next thing in newText
then post(plrName,text)--it posts with the name of the plr,and the text
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
16 Apr 2014 01:20 AM
Your hashtag method is probably as useful as just using
table.insert(newText,pos,'#')

Since your filter can only rip one letter at a time.
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
16 Apr 2014 01:24 AM
can you stop saying how horrible my script is and actually help..?

wheres wazap when u need im?
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
16 Apr 2014 01:24 AM
function post(name,msg)
for i,v in pairs(game.Players:GetChildren()) do
ypcall(function()
local chat = game.Lighting.Chat:clone()
chat.Parent = v:WaitForChild("PlayerGui").ChatGui--I'm surprised this doesnt error
chat.Text = (name..":"..msg)
game.Debris:AddItem(chat,4)
end)
end
end

function hashtag(num)
local t = ""
if num>0 then
for i=1,num do
t = t.."#"
end
end
return t
end

function Changed()
text = script.Parent.Parent.Text
plrName = script.Parent.Value
Swears = {"F","No"}
for i,v in pairs(Swears) do
while text:match(v) do
text=text:sub(1, text:find(v))..hashtag(#v)..text:sub(text:find(v)+#v)
end
end
post(plrName,text)
end

script.Parent.Changed:connect(Changed)

Cleaned up a ton of code
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
16 Apr 2014 01:24 AM
woah,NICEEE
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
16 Apr 2014 01:26 AM
gah,my script just lagged >_<
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
16 Apr 2014 01:29 AM
function post(name,msg)
for i,v in pairs(game.Players:GetChildren()) do
ypcall(function()
local chat = game.Lighting.Chat:clone()
chat.Parent = v:WaitForChild("PlayerGui").ChatGui--I'm surprised this doesnt error
chat.Text = (name..":"..msg)
game.Debris:AddItem(chat,4)
end)
end
end

function Changed()
text = script.Parent.Parent.Text
plrName = script.Parent.Value
Swears = {"F","No"}
for i,v in pairs(Swears) do
while text:match(v) do
text=text:sub(1, text:find(v))..'#':rep(#v)..text:sub(text:find(v)+#v)
end
end
post(plrName,text)
end

script.Parent.Changed:connect(Changed)

More efficiency. Took out an entire function.
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
16 Apr 2014 01:41 AM
-- Even more efficient... Ja?

function post(name,msg)
for i,v in pairs(game.Players:GetChildren()) do
ypcall(function()
local chat = game.Lighting.Chat:clone()
chat.Parent = v:WaitForChild("PlayerGui").ChatGui--I'm surprised this doesnt error
chat.Text = (name..":"..msg)
game.Debris:AddItem(chat,4)
end)
end
end

function Changed()
text = script.Parent.Parent.Text
plrName = script.Parent.Value
Swears = {"F","No"}
for i,v in pairs(Swears) do
text=text:gsub(v,('#'):rep(#v))
end
post(plrName,text)
end

script.Parent.Changed:connect(Changed)


Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
16 Apr 2014 01:52 AM
And more

Swears = {"F","No"}

function post(name,msg)
for i,v in pairs(game.Players:GetPlayers()) do
ypcall(function()
local chat = game.Lighting.Chat:clone()
chat.Parent = v.PlayerGui.ChatGui
chat.Text = (name..":"..msg)
game.Debris:AddItem(chat,4)
end)
end
end

function Changed(val)
text = script.Parent.Parent.Text
plrName = val
for i,v in pairs(Swears) do
text=text:gsub(v,('#'):rep(#v))
end
post(plrName,text)
end

script.Parent.Changed:connect(Changed)
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
16 Apr 2014 01:57 AM
I wonder if problems arise from the fact the only thing that fires is changing a value to a value that should remain the same (the player name)"...

I guess if he didn't experience it, it's all good.
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
16 Apr 2014 02:00 AM
@Beb I thought about that and was considering changing it to the TextLabel.Changed. But oh well.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image