Vyxium
|
  |
| Joined: 31 Aug 2010 |
| Total Posts: 1020 |
|
|
| 24 Mar 2014 08:12 PM |
Can somebody help me fix this script? I have a NumberValue that is initially 0 but every time a player says "regen", it makes the value go up by 1, and if the value reaches a certain number, it regens the cart in my game. The problem is, it just kept regenerating the carts as soon as the server started. I did not even chat anything and it just kept regenerating, probably because of the loop. Here is the script that regenerates the cart:
numpls = #game.Players:GetChildren() numvts = script.Parent.Value
a = game.Workspace.Cart:Clone()
while wait() do if numvts >= numpls * 0.50 then a:Clone().Parent = game.Workspace end end
--If you wanna see the other script that adds the value when chatted just ask. |
|
|
| Report Abuse |
|
|
tery215
|
  |
| Joined: 19 Aug 2009 |
| Total Posts: 3879 |
|
|
| 24 Mar 2014 08:13 PM |
numpls = #game.Players:GetChildren() numvts = script.Parent.Value
a = game.Workspace.Cart:Clone()
while wait() do if numvts >= numpls * 0.50 then numpls = 0 a:Clone().Parent = game.Workspace end end
--If you wanna see the other script that adds the value when chatted just ask. |
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 24 Mar 2014 08:15 PM |
Can somebody help me fix this script? I have a NumberValue that is initially 0 but every time a player says "regen", it makes the value go up by 1, and if the value reaches a certain number, it regens the cart in my game. The problem is, it just kept regenerating the carts as soon as the server started. I did not even chat anything and it just kept regenerating, probably because of the loop. Here is the script that regenerates the cart:
a = game.Workspace.Cart:Clone()
script.Parent.Changed:connect(function(numvsts) if numvts >= #game.Players:players()* 0.50 then a:Clone().Parent = game.Workspace end end)
--If you wanna see the other script that adds the value when chatted just ask.
|
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 24 Mar 2014 08:16 PM |
| Ignore the fact it's a copy and paste lol. |
|
|
| Report Abuse |
|
|
Vyxium
|
  |
| Joined: 31 Aug 2010 |
| Total Posts: 1020 |
|
|
| 24 Mar 2014 08:16 PM |
| And what will that do? numpls is the number of players and I want it to regen if 50% of the players chat regen |
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 24 Mar 2014 08:17 PM |
The problem is the numbers never updates.
I just added supposed efficiently =P. |
|
|
| Report Abuse |
|
|
Vyxium
|
  |
| Joined: 31 Aug 2010 |
| Total Posts: 1020 |
|
|
| 24 Mar 2014 08:19 PM |
| thats why I put the loop so it continuously checks if the number updates, I have another script that updates the numbers |
|
|
| Report Abuse |
|
|
Vyxium
|
  |
| Joined: 31 Aug 2010 |
| Total Posts: 1020 |
|
|
| 24 Mar 2014 08:22 PM |
| Ok well, it clones it when you say regen but it all falls apart when it gets cloned... |
|
|
| Report Abuse |
|
|
BogyMac
|
  |
| Joined: 04 Nov 2011 |
| Total Posts: 823 |
|
| |
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 24 Mar 2014 08:24 PM |
Vacuum, you defined the numbers ONCE and ONCE only.
That number will remain the same.
And when you clone it, use :MakeJoints() on it. |
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 24 Mar 2014 08:25 PM |
| Autocorrect called you vacuum, sorry. |
|
|
| Report Abuse |
|
|
Vyxium
|
  |
| Joined: 31 Aug 2010 |
| Total Posts: 1020 |
|
|
| 24 Mar 2014 08:27 PM |
| That's what I thought but I'm not too familiar with :MakeJoints(), do I do it before or after it gets cloned? |
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
| |
|
Vyxium
|
  |
| Joined: 31 Aug 2010 |
| Total Posts: 1020 |
|
|
| 24 Mar 2014 08:30 PM |
So this is all I have to do?
numpls = #game.Players:players() numvts = script.Parent.Value
a = game.Workspace.Cart:Clone()
script.Parent.Changed:connect(function(numvts) if numvts >= numpls * 0.50 then game.Workspace.Cart:Remove() a:Clone().Parent = game.Workspace a:MakeJoints() end end) |
|
|
| Report Abuse |
|
|
Vyxium
|
  |
| Joined: 31 Aug 2010 |
| Total Posts: 1020 |
|
|
| 24 Mar 2014 08:33 PM |
| Yea, that did not work at all ^^ |
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 24 Mar 2014 08:37 PM |
So this is all I have to do?
numpls = game.Players
a = game.Workspace.Cart:Clone()
script.Parent.Changed:connect(function(numvts) if numvts >= numpls.NumPlayer*0.50 then game.Workspace.Cart:Remove() local clone = a:clone() clone:MakeJoints() a.Parent = game.Workspace end end)
|
|
|
| Report Abuse |
|
|
Vyxium
|
  |
| Joined: 31 Aug 2010 |
| Total Posts: 1020 |
|
| |
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 24 Mar 2014 08:40 PM |
Add an s to NumPlayer So,it's NumPlayers |
|
|
| Report Abuse |
|
|
Vyxium
|
  |
| Joined: 31 Aug 2010 |
| Total Posts: 1020 |
|
|
| 24 Mar 2014 08:48 PM |
| I kinda just took parts from all the scripts lol so I got all kinds of variables but i know what u mean. |
|
|
| Report Abuse |
|
|
Vyxium
|
  |
| Joined: 31 Aug 2010 |
| Total Posts: 1020 |
|
|
| 24 Mar 2014 08:53 PM |
ahhhhh, don't you just love that feeling when you get a script to work? :D
but now does it work with more than 1 person? 0. o
|
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
| |
|