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
 

Re: Why doesn't this script work?

Previous Thread :: Next Thread 
bigbadvulture is not online. bigbadvulture
Joined: 16 May 2012
Total Posts: 351
08 Oct 2015 02:50 PM
while true do
wait(10)

local player = game.Players:GetChildren()
for i = 1, #player do
msg = game.Workspace.Value

msg.Parent = game.Workspace
msg.Value = "Choosing a map..."
wait(3)
msg.Value = "Starting a round.."
game.ServerStorage.Map_city:clone().Parent = game.Workspace
wait(3)
msg.Value = "Teleporting..."
wait(3)
player[i].Character:MoveTo(Vector3.new(44.065, 2.5, 4.002))
wait(.5)
game.ServerStorage.Handgun:clone().Parent = player[i].Backpack
game.ServerStorage.twod:clone().Parent = player[i].Backpack
msg.Value = "Round in progress..."
wait(60)
msg.Parent = game.Workspace
msg.Value = "Round over"
wait(3)
game.Workspace.Map_city:Remove()
wait(1)
end
end

It will only affect the first player in the server, why doesn't it cycle through all the players? Yes, I am aware this is written horribly, and it doesn't have a compatibility for multiple maps yet.
Report Abuse
rockandgreen is not online. rockandgreen
Joined: 20 Dec 2011
Total Posts: 1161
08 Oct 2015 02:54 PM
because you are basically running a whole round for each player in the server
your script is basically saying
for 1, to the last player in server do
the whole round
end
so the whole round will effect the first player and then the second and then the third.
Report Abuse
rockandgreen is not online. rockandgreen
Joined: 20 Dec 2011
Total Posts: 1161
08 Oct 2015 02:55 PM
It does cycle through all the players but it doesn't do parts of the rounds to all players but it does whole rounds to each of the players so your syntax is fine but your script logic is wrong.
Report Abuse
bigbadvulture is not online. bigbadvulture
Joined: 16 May 2012
Total Posts: 351
08 Oct 2015 02:56 PM
However it only works for the first player.
Report Abuse
bigbadvulture is not online. bigbadvulture
Joined: 16 May 2012
Total Posts: 351
08 Oct 2015 02:56 PM
I'll try and fix it, thanks.
Report Abuse
Kenvarus is not online. Kenvarus
Joined: 21 Apr 2009
Total Posts: 57
08 Oct 2015 03:00 PM
i think its cause you have it set to detect the number of players as 1, you need to make the for i=1 dynamically detect the number of players... i think something like
for i > 1, #player do
not rly sure if that would work but im pretty sure that i = 1 is the issue

mind you im a VERY inexperienced scripter
Report Abuse
rockandgreen is not online. rockandgreen
Joined: 20 Dec 2011
Total Posts: 1161
08 Oct 2015 03:00 PM
Dude, for i = 1,#player do doesn't work like the way you are trying to use it.
Basically the code between "for i = 1,#player" and "end" runs once to the first player. Then again to the second. And then the third. And this keeps on going until the last player. If you want it to work for all players at once rather then doing a whole round for just one person at a time then you need to make separate for i loops for each part of the round. Then it will work.
Report Abuse
Kenvarus is not online. Kenvarus
Joined: 21 Apr 2009
Total Posts: 57
08 Oct 2015 03:00 PM
lol i type very slow, he responded to you in the 5 minutes i was typing :P
Report Abuse
Kenvarus is not online. Kenvarus
Joined: 21 Apr 2009
Total Posts: 57
08 Oct 2015 03:01 PM
its cause i have to keep re-typing as i try and decide how to work every little thing... i overthink things
Report Abuse
rockandgreen is not online. rockandgreen
Joined: 20 Dec 2011
Total Posts: 1161
08 Oct 2015 03:02 PM
No ken, as I said, his syntax is fine for the actual loop. The way he is using the loop is wrong. It's like getting all the players in the server into a long queue and running the round for the first person and then the second and then the third and so on. He says it only effects the first player because he made a whole round happen for one player at a time. After doing a round it will move on to the second player. This is not how a round should work as it should involve all players at the same time not just 1. That's his problem.
Report Abuse
Kenvarus is not online. Kenvarus
Joined: 21 Apr 2009
Total Posts: 57
08 Oct 2015 03:02 PM
while true do
wait(10)

local player = game.Players:GetChildren()
msg = game.Workspace.Value

msg.Parent = game.Workspace
msg.Value = "Choosing a map..."
wait(3)
msg.Value = "Starting a round.."
game.ServerStorage.Map_city:clone().Parent = game.Workspace
wait(3)
msg.Value = "Teleporting..."
wait(3)
for i = 1, #player do
player[i].Character:MoveTo(Vector3.new(44.065, 2.5, 4.002))
wait(.5)
game.ServerStorage.Handgun:clone().Parent = player[i].Backpack
game.ServerStorage.twod:clone().Parent = player[i].Backpack
msg.Value = "Round in progress..."
wait(60)
msg.Parent = game.Workspace
msg.Value = "Round over"
wait(3)
game.Workspace.Map_city:Remove()
wait(1)
end
end

try that
Report Abuse
Kenvarus is not online. Kenvarus
Joined: 21 Apr 2009
Total Posts: 57
08 Oct 2015 03:03 PM
while true do
wait(10)

local player = game.Players:GetChildren()
msg = game.Workspace.Value

msg.Parent = game.Workspace
msg.Value = "Choosing a map..."
wait(3)
msg.Value = "Starting a round.."
game.ServerStorage.Map_city:clone().Parent = game.Workspace
wait(3)
msg.Value = "Teleporting..."
wait(3)
for i = 1, #player do
player[i].Character:MoveTo(Vector3.new(44.065, 2.5, 4.002))
end
wait(.5)
game.ServerStorage.Handgun:clone().Parent = player[i].Backpack
game.ServerStorage.twod:clone().Parent = player[i].Backpack
msg.Value = "Round in progress..."
wait(60)
msg.Parent = game.Workspace
msg.Value = "Round over"
wait(3)
game.Workspace.Map_city:Remove()
wait(1)
end

or that, im not sure which
Report Abuse
rockandgreen is not online. rockandgreen
Joined: 20 Dec 2011
Total Posts: 1161
08 Oct 2015 03:04 PM
player[i].Character:MoveTo(Vector3.new(44.065, 2.5, 4.002))
wait(.5)
game.ServerStorage.Handgun:clone().Parent = player[i].Backpack
game.ServerStorage.twod:clone().Parent = player[i].Backpack
msg.Value = "Round in progress..."
wait(60)
msg.Parent = game.Workspace
msg.Value = "Round over"
wait(3)
game.Workspace.Map_city:Remove()
wait(1)

Will run once for one player. It will then finish on that player and move on to the next one. Do you see the problem?
Report Abuse
rockandgreen is not online. rockandgreen
Joined: 20 Dec 2011
Total Posts: 1161
08 Oct 2015 03:05 PM
Dude you are still running a WHOLE ROUND for ONE PERSON. It won't work.
Report Abuse
rockandgreen is not online. rockandgreen
Joined: 20 Dec 2011
Total Posts: 1161
08 Oct 2015 03:05 PM
Anyways I have to go now goodluck trying to fix this.
Report Abuse
bigbadvulture is not online. bigbadvulture
Joined: 16 May 2012
Total Posts: 351
08 Oct 2015 03:07 PM
Ken, the second one sorta works, it will teleport everyone, however it doesn't give them the script, or tools during the round. I think I might be able to fix it, but I'm not sure.
Report Abuse
Kenvarus is not online. Kenvarus
Joined: 21 Apr 2009
Total Posts: 57
08 Oct 2015 03:08 PM
hes propably right i dont rly know waht im talking about i pretty much just try stuff like that till it works when i have script issues :P
Report Abuse
Kenvarus is not online. Kenvarus
Joined: 21 Apr 2009
Total Posts: 57
08 Oct 2015 03:08 PM
if the second one works then just move the end i moved to right after the item-backpack moving part
Report Abuse
Kenvarus is not online. Kenvarus
Joined: 21 Apr 2009
Total Posts: 57
08 Oct 2015 03:09 PM
wait(.5)
game.ServerStorage.Handgun:clone().Parent = player[i].Backpack
game.ServerStorage.twod:clone().Parent = player[i].Backpack
end
Report Abuse
bigbadvulture is not online. bigbadvulture
Joined: 16 May 2012
Total Posts: 351
08 Oct 2015 03:09 PM
It kind of worked, the problem in theory is there may have been leftover from the old script in your second version.
Report Abuse
Kenvarus is not online. Kenvarus
Joined: 21 Apr 2009
Total Posts: 57
08 Oct 2015 03:10 PM
while true do
wait(10)

local player = game.Players:GetChildren()
msg = game.Workspace.Value

msg.Parent = game.Workspace
msg.Value = "Choosing a map..."
wait(3)
msg.Value = "Starting a round.."
game.ServerStorage.Map_city:clone().Parent = game.Workspace
wait(3)
msg.Value = "Teleporting..."
wait(3)
for i = 1, #player do
player[i].Character:MoveTo(Vector3.new(44.065, 2.5, 4.002))
wait(.5)
game.ServerStorage.Handgun:clone().Parent = player[i].Backpack
game.ServerStorage.twod:clone().Parent = player[i].Backpack
end
msg.Value = "Round in progress..."
wait(60)
msg.Parent = game.Workspace
msg.Value = "Round over"
wait(3)
game.Workspace.Map_city:Remove()
wait(1)
end
Report Abuse
Kenvarus is not online. Kenvarus
Joined: 21 Apr 2009
Total Posts: 57
08 Oct 2015 03:11 PM
then throw the whole thing into a function instead of having it be open maybe? idk ive got good instincts but i do not actually know how to script, i just have a basic understanding of the "grammer"
Report Abuse
bigbadvulture is not online. bigbadvulture
Joined: 16 May 2012
Total Posts: 351
08 Oct 2015 03:11 PM
Thanks, it worked!
Report Abuse
bigbadvulture is not online. bigbadvulture
Joined: 16 May 2012
Total Posts: 351
08 Oct 2015 03:14 PM
Now that it works, I need to make make it more efficient.
Report Abuse
Kenvarus is not online. Kenvarus
Joined: 21 Apr 2009
Total Posts: 57
08 Oct 2015 03:14 PM
Awesome :P
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