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: A script that saves what team you are on?

Previous Thread :: Next Thread 
sweis12 is not online. sweis12
Joined: 08 Feb 2013
Total Posts: 2522
29 Dec 2012 10:19 PM

lets say, there is checkpoints, and these checkpoints are teams. Is there a way for when they log out, it automaticly saves? Then when they log back in, no matter what server it will put them back at that team spawn point? If so, can soemone build it for me? I am willing to pay R$.
Report Abuse
crouton04 is not online. crouton04
Joined: 07 Jul 2010
Total Posts: 4459
29 Dec 2012 10:25 PM
TeamValue1
TeamValue2

TeamChosen,

TeamValue1 = true
TeamValue2 = false

game.Players.LocalPlayer:SaveBoolean("TeamValue1", true)

TeamValue1 = false
TeamValue2 = true

game.Players.LocalPlayer:SaveBoolean("TeamValue2", true)

Report Abuse
sweis12 is not online. sweis12
Joined: 08 Feb 2013
Total Posts: 2522
29 Dec 2012 10:28 PM
Would that work with more then two teams though?
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
29 Dec 2012 10:29 PM
If you have several teams, you could just save the TeamColor they're on.

Game.Players.PlayerAdded:connect(function(Plr)
Plr:WaitForDataReady()
Plr.TeamColor = BrickColor.new(Color3.new(Plr:LoadNumber("RED"),Plr:LoadNumber("BLUE"),Plr:LoadNumber("GREEN")))
end)

Game.Players.PlayerRemoving:connect(function(Plr)
local team = Plr.TeamColor
Plr:SaveNumber("RED", team.r)
Plr:SaveNumber("BLUE", team.b)
Plr:SaveNumber("GREEN", team.g)
end)
Report Abuse
crouton04 is not online. crouton04
Joined: 07 Jul 2010
Total Posts: 4459
29 Dec 2012 10:30 PM
Thats not the script.. Just add more, if a team is chosen, save the team as soon as it is chosen. :p You can save the teamcolor if you want.
Report Abuse
sweis12 is not online. sweis12
Joined: 08 Feb 2013
Total Posts: 2522
29 Dec 2012 10:34 PM
@Crouton
Didn't work

@Kill
Testing, thanks. Also, do I have to change the temacolors too the ones I have?
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
29 Dec 2012 10:36 PM
No, don't change anything.
Report Abuse
sweis12 is not online. sweis12
Joined: 08 Feb 2013
Total Posts: 2522
29 Dec 2012 10:39 PM
It does not appear to be working at all.
Report Abuse
crouton04 is not online. crouton04
Joined: 07 Jul 2010
Total Posts: 4459
29 Dec 2012 10:46 PM
Why are you using savenumber?
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
29 Dec 2012 10:52 PM
Because there is no "SaveBrickColor" method.

I suppose if that doesn't work, you'll have to use this:

Game.Players.PlayerAdded:connect(function(Plr)
Plr:WaitForDataReady()
local team = Plr:LoadString("TEAM")
for i, v in pairs(Game.Teams) do
if v.Name == team then
Plr.TeamColor = v.TeamColor
break
end
end
end)

Game.Players.PlayerRemoving:connect(function(Plr)
Plr:SaveString("TEAM", (function()
local team = Plr:LoadString("TEAM")
for i, v in pairs(Game.Teams) do
if v.Name == team then
return v.TeamColor
end
end
end)()) end)
Report Abuse
sweis12 is not online. sweis12
Joined: 08 Feb 2013
Total Posts: 2522
29 Dec 2012 10:52 PM
Someone, please halp.
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
29 Dec 2012 10:52 PM
Replace "Game.Teams" with "Game.Teams:GetChildren()"
Report Abuse
sweis12 is not online. sweis12
Joined: 08 Feb 2013
Total Posts: 2522
29 Dec 2012 10:59 PM
So like this? Game.Players.PlayerAdded:connect(function(Plr)
Plr:WaitForDataReady()
local team = Plr:LoadString("TEAM")
for i, v in pairs(Game.Teams) do
if v.Name == team then
Plr.TeamColor = v.TeamColor
break
end
end
end)

Game.Players.PlayerRemoving:connect(function(Plr)
Plr:SaveString("TEAM", (function()
local team = Plr:LoadString("TEAM")
for i, v in pairs(Game.Teams:GetChildren()) do
if v.Name == team then
return v.TeamColor
end
end
end)()) end)

Or this?

Game.Players.PlayerAdded:connect(function(Plr)
Plr:WaitForDataReady()
local team = Plr:LoadString("TEAM")
for i, v in pairs(Game.Teams) do
if v.Name == team then
Plr.TeamColor = v.TeamColor
break
end
end
end)

Game.Players.PlayerRemoving:connect(function(Plr)
Plr:SaveString("TEAM", (function()
local team = Plr:LoadString("TEAM")
for i, v in pairs(Game.Teams:GetChildren() do
if v.Name == team then
return v.TeamColor
end
end
end)()) end)
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
29 Dec 2012 11:01 PM
Both Game.Teams. Use this (I also corrected another mistake):

Game.Players.PlayerAdded:connect(function(Plr)
Plr:WaitForDataReady()
local team = Plr:LoadString("TEAM")
for i, v in pairs(Game.Teams:GetChildren()) do
if v.Name == team then
Plr.TeamColor = v.TeamColor
break
end
end
end)

Game.Players.PlayerRemoving:connect(function(Plr)
Plr:SaveString("TEAM", (function()
for i, v in pairs(Game.Teams:GetChildren() do
if v.Name == team then
return v.Name
end
end
end)()) end)
Report Abuse
sweis12 is not online. sweis12
Joined: 08 Feb 2013
Total Posts: 2522
29 Dec 2012 11:06 PM
still does not work :(
Le que que
Report Abuse
sweis12 is not online. sweis12
Joined: 08 Feb 2013
Total Posts: 2522
29 Dec 2012 11:18 PM
le bump bump
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
29 Dec 2012 11:33 PM
Is one of the teams AutoAssignable?
Report Abuse
sweis12 is not online. sweis12
Joined: 08 Feb 2013
Total Posts: 2522
29 Dec 2012 11:33 PM
Yes, the first one.
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
29 Dec 2012 11:36 PM
I guess that was a pretty irrelevant question. Try this:


local StartingTeamColor = "name of starting team"

Game.Players.PlayerAdded:connect(function(Plr)
Plr:WaitForDataReady()
local cteam = Plr:LoadString("TEAM")
local team = cteam == "" and cteam or StartingTeamColor
for i, v in pairs(Game.Teams:GetChildren()) do
if v.Name == team then
Plr.TeamColor = v.TeamColor
break
end
end
end)

Game.Players.PlayerRemoving:connect(function(Plr)
Plr:SaveString("TEAM", (function()
for i, v in pairs(Game.Teams:GetChildren() do
if v.Name == team then
return v.Name
end
end
end)()) end)
Report Abuse
sweis12 is not online. sweis12
Joined: 08 Feb 2013
Total Posts: 2522
29 Dec 2012 11:37 PM
The name, or team color?
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
29 Dec 2012 11:38 PM
Name... it was originally going to be color, but I changed it.

If this doesn't work, I give up. I am absolutely terrible at DataPersistance- I've never really used it before.
Report Abuse
sweis12 is not online. sweis12
Joined: 08 Feb 2013
Total Posts: 2522
29 Dec 2012 11:41 PM
Yea, IT dosn't work. Im confused on this subject though. The script SHOULD be working.
Report Abuse
Treshold is not online. Treshold
Joined: 01 Aug 2012
Total Posts: 109
29 Dec 2012 11:50 PM
Why not just save TeamColor.Number?


game.Players.PlayerAdded:connect(function(plr)
plr:WaitForDataReady()
if not plr:LoadNumber("Team") then return end
plr.TeamColor = BrickColor.new(plr:LoadNumber("Team"))
end)

game.Players.PlayerRemoving:connect(function(plr)
plr:SaveNumber("Team",plr.TeamColor.Number)
end)
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
29 Dec 2012 11:51 PM
^

Forgot BrickColor.Number existed. qq
Report Abuse
thedestroyer115 is not online. thedestroyer115
Joined: 19 Dec 2010
Total Posts: 11546
30 Dec 2012 12:13 AM
Or just save it as a stringvalue. Look:


game.Players.PlayerRemoving:connect(function(player)
player:SaveBoolean("PBF", true)
player:SaveString("Team", tostring(player.TeamColor)
end)


game.Players.PlayerAdded:connect(function(player)
if player:LoadBoolean("PBF") == true then
player.TeamColor = BrickColor.new(tostring(player:LoadString("Team")))
end end)


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