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 » Scripters
Home Search
 

This module is driving me nuts too!

Previous Thread :: Next Thread 
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
15 Jan 2017 03:11 PM
For all intents and purposes it does technically work, but it's spawning two copies of each player.

Like Ill have Player1, Player2, and Player3, and then it takes those players and creates information for them in a different folder.

The problem being, however, is that it seems to create two copies per player, and probably 3 if the number of teams is set to 3 i bet. I bet you it would.
But each "packet", i guess i can call it, of information created puts the same player on all the teams.

Like right now the number of teams is manually set to 2 for testing purposes, and it clones two things of information for all the players, so like it makes a new thing for Player1 and puts the value on Bright red, and then creates another thing for the same Player1 but places that value as Bright blue and it does this for all the players

Now I have gone through this code multiple times and I just can't figure out why it's doing that.

The whole point of this script is to divide players evenly among the teams.



local CTable = {"Bright red", "Bright blue", "Bright yellow", "Bright green"}
local CTNum = 1

function ModuleMapFunction()
local TC = game.ServerStorage.Assets.TeamColors
local NOT = game.ServerStorage.Assets.NumberOfTeams
local Ready = game.ReplicatedStorage.Ready
local CP = game.ReplicatedStorage.CurrentPlayers
local MLives = game.ServerStorage.Assets.MaxLives.Value
local ReadyP = Ready:GetChildren()
for q = 1, #ReadyP do
local PString = Instance.new("StringValue", CP)
PString.Name = ReadyP[q].Name
PString.Value = CTable[CTNum]
if CTNum == NOT.Value then
CTNum = 1
else
CTNum = CTNum + 1
end
local KInt = Instance.new("IntValue", PString)
KInt.Name = "Kills"; KInt.Value = 0
local DInt = Instance.new("IntValue", PString)
DInt.Name = "Deaths"; DInt.Value = 0
local LInt = Instance.new("IntValue", PString)
LInt.Name = "Lives"; LInt.Value = MLives
end

for w = 1, NOT.Value do wait()
local Station = game.ServerStorage.Assets.Station:Clone()

Station.Parent = game.Workspace.GameFolder
Station.BrickColor = BrickColor.new(CTable[w])
Station.Name = "Station [" ..CTable[w].. "]"
Station.CFrame = CFrame.new(0, 0, 0)
* CFrame.Angles(0, math.rad(((360/NOT.Value) * w) - (360/NOT.Value)), 0)
* CFrame.new(0, 0, 3500)
* CFrame.Angles(0, math.rad(90), 0)

end


game.ServerStorage.ModuleBool.Value = true
end

return ModuleMapFunction
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
15 Jan 2017 03:17 PM
My common sense tells me it has to do with this chunk of code right here.
That doesn't make sense, though because it's creating a for loop based on the number of players whose names were placed into the Ready folder, I.E. the players ready to play.

It's then supposed to cycle through that table one time and create gameplay information for the players in a different folder.
Using the NOT.Value as a guide, the NumberOfTeams, it checks to see if CTNum is equal to NOT.Value and if it is, reset CTNum to 1, or else it just adds +1 to it, while the script uses that CTNum to find the info in the team colors table.

I don't see anywhere in this chunk OR the entire script where it would cause it to duplicate a player

local ReadyP = Ready:GetChildren()
for q = 1, #ReadyP do
local PString = Instance.new("StringValue", CP)
PString.Name = ReadyP[q].Name
PString.Value = CTable[CTNum]
if CTNum == NOT.Value then
CTNum = 1
else
CTNum = CTNum + 1
end
local KInt = Instance.new("IntValue", PString)
KInt.Name = "Kills"; KInt.Value = 0
local DInt = Instance.new("IntValue", PString)
DInt.Name = "Deaths"; DInt.Value = 0
local LInt = Instance.new("IntValue", PString)
LInt.Name = "Lives"; LInt.Value = MLives
end
Report Abuse
TehIcyStar is not online. TehIcyStar
Joined: 07 Mar 2010
Total Posts: 1649
15 Jan 2017 03:18 PM
Check the logic of your script. If you have it do something more than you want it to, you're looping a loop incorrectly. (or something like that)

Shove prints everywhere to see what code is being run when. Here's an example of how I would debug this myself:

function StartScramble()
print("Scramble start")
...
for i,v in pairs(game.Players:GetChildren()) do
print("scrambling "..v.Name)
...
if v.SomeVal < 3 then
print("If passed")
else
print("If failed")
end
end
end

now if I see "Scramble Start" twice in the console, I would know that the function is called twice for some reason.
If I see "Scrambling Player1" twice, I would know that the function is fine but the loop is doing done twice. You get the idea.

Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
15 Jan 2017 03:21 PM
Quick update. It seems to do it randomly. Sometimes it dupes them and sometimes it does not. I am so confused right now... And there are so many other problems with other code I just don't know how to fix...
Report Abuse
TehIcyStar is not online. TehIcyStar
Joined: 07 Mar 2010
Total Posts: 1649
15 Jan 2017 03:32 PM
Yep, coding is hard. The only way to pinpoint the problem is to see exactly when and where the code goes. The only way to have a bird's-eye view of the code is using these print statements
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
15 Jan 2017 03:46 PM
That's the problem, though. It's not supposed to loop a loop. It's just supposed to iterate through the players once. That's it. It's not supposed to do it twice.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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