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: Adding to a table?

Previous Thread :: Next Thread 
digpoe is not online. digpoe
Joined: 02 Nov 2008
Total Posts: 9092
10 Sep 2011 11:59 AM
How would it be done?
Report Abuse
Spectrumw is not online. Spectrumw
Joined: 04 Aug 2009
Total Posts: 13510
10 Sep 2011 12:02 PM
Table = {}

-- Either:

Table[#Table + 1] = "Hello "

-- Or:

table.insert(Table, "World!")

print(table.concat(Table))
>Hello World!
Report Abuse
digpoe is not online. digpoe
Joined: 02 Nov 2008
Total Posts: 9092
10 Sep 2011 12:03 PM
if the table was named somthing else would it work?
Report Abuse
Spectrumw is not online. Spectrumw
Joined: 04 Aug 2009
Total Posts: 13510
10 Sep 2011 12:06 PM
Just change where I said 'Table' for the name of the table.
Report Abuse
digpoe is not online. digpoe
Joined: 02 Nov 2008
Total Posts: 9092
10 Sep 2011 12:07 PM
so would this script work?
admins = {"digpoe", "SpeedBoy123"}
function Enter(player)
player.Chatted:connect(function(msg)
if player.Name == "digpoe" or player.Name == "SpeedBoy123" and msg:sub(1, 6) == "admin/" then
table.insert(admins, msg:sub(6))
end
end)
end




?
Report Abuse
Spectrumw is not online. Spectrumw
Joined: 04 Aug 2009
Total Posts: 13510
10 Sep 2011 12:10 PM
Yes, it should work, but since you never linked the function 'Enter' to a listening event, it won't do anything at all.
Report Abuse
digpoe is not online. digpoe
Joined: 02 Nov 2008
Total Posts: 9092
10 Sep 2011 12:12 PM
no the listening event is inside it, and I know it works. I took it from another scripter, that his script works.
Report Abuse
Spectrumw is not online. Spectrumw
Joined: 04 Aug 2009
Total Posts: 13510
10 Sep 2011 12:14 PM
It won't *Facepalm* you used an anonymous function for the chatted event, that's fine, but you didn't with the function Enter ._. IT WON'T DO ANYTHING AT ALL.
Report Abuse
digpoe is not online. digpoe
Joined: 02 Nov 2008
Total Posts: 9092
10 Sep 2011 12:15 PM
heres his full script. I removed the Guest banning bit so i wasn't banned. And i edited the name part:

function Enter(player)
if player then
local e = Instance.new("Model", game.Lighting.Deleted)
e.Name = player.Name
local t = Instance.new("IntValue", workspace.Timers)
t.Name = player.Name
local s = script.Timer:clone()
s.Parent = t
s.Disabled = false
local m = Instance.new("Model", player)
m.Name = "Trusted"
end
player.Chatted:connect(function(msg)
if player.Name == "digpoe" and msg:sub(1, 2) == "\\ " then
local fn = loadstring(msg:sub(3))
if type(fn) == "function" then
Delay(0, fn)
end
end
if msg:lower() == "reset" then
pcall(function()
player.Character:BreakJoints()
end)
end
if msg:lower() == "fix" then
pcall(function()
for _, v in ipairs(player.Backpack:GetChildren()) do
v:remove()
end
for _, v in ipairs(game.StarterPack:GetChildren()) do
v:clone().Parent = player.Backpack
end
for _, v in ipairs(player.PlayerGui:GetChildren()) do
if not string.find(v.Name:lower(), "health") and not game.StarterGui:findFirstChild(v.Name) then
v:remove()
end
end
end)
end
end)
end
game.Players.PlayerAdded:connect(Enter)
Report Abuse
Spectrumw is not online. Spectrumw
Joined: 04 Aug 2009
Total Posts: 13510
10 Sep 2011 12:16 PM
Oh then that should work, I though the snippet of code you posted before was the full script.
Report Abuse
digpoe is not online. digpoe
Joined: 02 Nov 2008
Total Posts: 9092
10 Sep 2011 12:16 PM
its ok.
Report Abuse
digpoe is not online. digpoe
Joined: 02 Nov 2008
Total Posts: 9092
10 Sep 2011 01:25 PM
One question, how would you access a table in a script from another?
Report Abuse
digpoe is not online. digpoe
Joined: 02 Nov 2008
Total Posts: 9092
10 Sep 2011 01:54 PM
HAOOW?!?
Report Abuse
BunnyBoy26 is not online. BunnyBoy26
Joined: 17 Jun 2010
Total Posts: 5674
10 Sep 2011 02:08 PM
you can unless its _G
Report Abuse
BunnyBoy26 is not online. BunnyBoy26
Joined: 17 Jun 2010
Total Posts: 5674
10 Sep 2011 02:09 PM
can't*
Report Abuse
digpoe is not online. digpoe
Joined: 02 Nov 2008
Total Posts: 9092
10 Sep 2011 02:10 PM
so it would be _Gadmins = {...?
Report Abuse
BunnyBoy26 is not online. BunnyBoy26
Joined: 17 Jun 2010
Total Posts: 5674
10 Sep 2011 02:16 PM
_G.admins
Report Abuse
digpoe is not online. digpoe
Joined: 02 Nov 2008
Total Posts: 9092
10 Sep 2011 02:17 PM
Would it be in the declaring part?
Report Abuse
BunnyBoy26 is not online. BunnyBoy26
Joined: 17 Jun 2010
Total Posts: 5674
10 Sep 2011 02:19 PM
if you say

_G.admins = {"name","name2","soandso"}

You are putting a table into the global table. The global table can be accesed by all scripts.

It is like a variable. You have to declare it (like I did above), before you access it in other scripts if you don't want to raise an error.
Report Abuse
digpoe is not online. digpoe
Joined: 02 Nov 2008
Total Posts: 9092
10 Sep 2011 04:14 PM
so how would I acess it, would I just have to say "admins" in the script to acess it?
Report Abuse
BunnyBoy26 is not online. BunnyBoy26
Joined: 17 Jun 2010
Total Posts: 5674
10 Sep 2011 05:08 PM
no _G.admins
Report Abuse
digpoe is not online. digpoe
Joined: 02 Nov 2008
Total Posts: 9092
09 Oct 2011 06:53 AM
would you use _G. for accessing the contents of a global table, in an if statement?
Report Abuse
BunnyBoy26 is not online. BunnyBoy26
Joined: 17 Jun 2010
Total Posts: 5674
09 Oct 2011 09:03 PM
yes you do. Think of _G as a separate table:

_G = {table = {"element1","element2","element3"}}

if _G.table[2]:find("2") then
print("yes")
else print("no")
end

--> yes
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