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: Uh oh. This isn't good.

Previous Thread :: Next Thread 
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
12 Mar 2014 08:46 PM
player = script.Parent
classes = script:GetChildren ()

function CheckClass ()
for i,v in pairs (classes) do
if v.Value then
class = v
end
end
end

player.CharacterAdded:connect (function ()
CheckClass ()
if player.TeamColor == BrickColor.new ('Cyan') then
game.ServerStorage.Classes.IF[class]:Clone ().Parent = player.Backpack
else game.ServerStorage.Classes.Allies[class]:Clone ().Parent = player.Backpack
end
end)

It's a loadout saver in an FPS (i.e. if you have the sniper class and die, you will still spawn with sniper tools).

classes is a set of BoolValues, each having the name of a class (hideous method, I know. This is the one that came to mind, though).

The script gives no errors, but doesn't distribute the tools after I die, either.
Report Abuse
jonesj627 is not online. jonesj627
Joined: 06 Oct 2010
Total Posts: 1496
12 Mar 2014 08:48 PM
function CheckClass ()
for i,v in pairs (classes) do
if v.Value then
class = v
end
end
end
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect (function ()
CheckClass ()
if player.TeamColor == BrickColor.new ('Cyan') then
game.ServerStorage.Classes.IF[class]:Clone ().Parent = player.Backpack
else game.ServerStorage.Classes.Allies[class]:Clone ().Parent = player.Backpack
end
end)
end)


--its good to be batman
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
12 Mar 2014 08:49 PM
Is that really necessary when you have a script inside the player?
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
12 Mar 2014 08:59 PM
bump. See ya tomorrow!
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
13 Mar 2014 03:10 PM
Guys, I think the problem is either here:

class = v

or here:

game.ServerStorage.Allies[class]:Clone ()
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
13 Mar 2014 03:25 PM
This is just syntax. I need to know the proper syntax.
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
13 Mar 2014 03:44 PM
Come on, guys!
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
13 Mar 2014 03:52 PM
This is a real stump. I mean this is my only job ATM, and it doesn't even work.
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
13 Mar 2014 03:55 PM
player = script.Parent
classes = script:GetChildren ()

function CheckClass ()
for i,v in pairs (classes) do
if v.Value then
class = v.Name --Ummmm XD
end
end
end

player.CharacterAdded:connect (function ()
CheckClass ()
if player.TeamColor == BrickColor.new ('Cyan') then
game.ServerStorage.Classes.IF[class]:Clone ().Parent = player.Backpack
else game.ServerStorage.Classes.Allies[class]:Clone ().Parent = player.Backpack
end
end)
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
13 Mar 2014 03:58 PM
Tried that too already. I made this change however, so I'll include it with that change:

player = script.Parent
classes = script:GetChildren ()

function CheckClass ()
for i,v in pairs (classes) do
if v.Value then
class = v.Name --this is incorporating the change.
end
end
end

player.CharacterAdded:connect (function ()
CheckClass ()
if player.TeamColor == BrickColor.new ('Cyan') then
stuff = game.ServerStorage.Classes.IF[class]:GetChildren ()
stuff:Clone ().Parent = player.Backpack
else stuff = game.ServerStorage.Classes.Allies[class]:GetChildren ()
stuff:Clone ().Parent = player.Backpack
end
end)
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
13 Mar 2014 04:09 PM
Not even this works:

if player.TeamColor == BrickColor.new ('Cyan') then
stuff = game.ServerStorage.Classes.IF.Assault:GetChildren () -- [class]:GetChildren ()
stuff:Clone ().Parent = player.Backpack
else stuff = game.ServerStorage.Classes.Allies.Assault:GetChildren () -- [class]:GetChildren ()
stuff:Clone ().Parent = player.Backpack
end
end)
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
13 Mar 2014 04:37 PM
:GetChildren() is a table -.-
for i, v loop it.
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
13 Mar 2014 04:39 PM
Erm..does ANYONE realize you can't run a script inside game.Players.Playername?
U can have a LocalScript in StarterGui,or StarterPack
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
13 Mar 2014 04:46 PM
This is all news to me.
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
13 Mar 2014 04:56 PM
just to test,go into server/or test solo
and insert a localscript into the player that says

p = script.Parent
print (p.Name)

there will be NO output..
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
13 Mar 2014 04:58 PM
Huh, wonder why that is...
Could you have it in StarterGear?
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
13 Mar 2014 05:03 PM
StarterGear?Don't you mean StarterPack?

StarterPack and StarterGui work:)

Just define player as game.Players.LocalPlayer
And have it as a localscript
Report Abuse
7y13rb is not online. 7y13rb
Joined: 28 May 2011
Total Posts: 223
13 Mar 2014 05:06 PM
--er.....shouldn't you need a wait also? if they respawn after it gives the tools
--it kinda defeats the purpose...also another way to do this:
--1-put the script in the tool itself(trust me)
--2-put tool in starterpack
--3-in the script:
local player = script.Parent.Parent.Parent:GetPlayerFromCharacter()
if player.TeamColor ~= "TEAMCOLORHERE" then --if they aren't on a team
script.Parent:Destroy() --Killcode
end
--basically it gives it to everyone, then if they aren't on a specific team, it
--destroys it.
Report Abuse
7y13rb is not online. 7y13rb
Joined: 28 May 2011
Total Posts: 223
13 Mar 2014 05:07 PM
You might need to change script i gave...i don't know where TeamColor is...i think its in player though
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
13 Mar 2014 05:09 PM
Btw,GetChildren() returns a table..
U have to use a for loop
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
13 Mar 2014 06:09 PM
@7yrb, sorry. Not what I'm looking for.

@Island, I do have the for loop now. If you put it in the StarterPack, do you need to have a script that distributes it?
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
13 Mar 2014 06:30 PM
pls
Report Abuse
roleo1122 is not online. roleo1122
Joined: 28 Jan 2013
Total Posts: 971
13 Mar 2014 07:27 PM
function CheckClass ()
for i,v in pairs (classes) do
if v.Value then
class = v
end
end
end
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect (function ()
CheckClass ()
if player.TeamColor == BrickColor.new ('Cyan') then
game.ServerStorage.Classes.IF[class]:Clone ().Parent = player.Backpack
else game.ServerStorage.Classes.Allies[class]:Clone ().Parent = player.Backpack
player.backpack[class]
end
end)
end)
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