|
| 13 Aug 2014 05:59 PM |
Currently I am trying to make a script that, when the server starts, there are 9 minutes and 40 seconds of invincibility. After those 9 minutes and 40 seconds there are 5 minutes of vulnerability where players are able to take damage from weapons again. Then the script repeats itself so that the players are invincible for 9 minutes and 40 seconds again, and so on.
This is what I have so far:
local waittime=1--in minutes local t=Instance.new("IntValue", Workspace) t.Value=waittime*60; function initialize(); game.Players.PlayerAdded:connect(function(p) p.CharacterAdded:connect(function(c) local isActive=t.Value > 0 if isActive then wait(0.5) c:WaitForChild("Humanoid").MaxHealth=math.huge; print(c.Humanoid.MaxHealth) end end) end)
t.Changed:connect(function() if t.Value < 2 then print'less than two doe' for _, v in pairs(game:GetService("Players"):GetPlayers()) do if v.Character and v.Character.Humanoid then v.Character.Humanoid.MaxHealth=100; end end end end)
for i=t.Value, 1, -1 do t.Value=i; wait(1) end
end
while true do initialize() wait(waittime*60) end
There is an error near the beginning of the script that I need help fixing and I also need help incorporating the time limits into the script. Just for some help, there are 300 seconds in 5 minutes and 580 seconds in 9 minutes and 40 seconds. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
L0cky2013
|
  |
| Joined: 30 Jul 2012 |
| Total Posts: 1446 |
|
|
| 13 Aug 2014 08:41 PM |
here
-.-
local waittime=1--in minutes local vulnerbilitytime=1--in minutes local t=Instance.new("IntValue", Workspace) t.Value=waittime*60; function initialize(); game.Players.PlayerAdded:connect(function(p) p.CharacterAdded:connect(function(c) local isActive=t.Value > 0 if isActive then wait(0.5) c:WaitForChild("Humanoid").MaxHealth=math.huge; print(c.Humanoid.MaxHealth) end end) end)
t.Changed:connect(function() if t.Value < 2 then print'less than two doe' for _, v in pairs(game:GetService("Players"):GetPlayers()) do if v.Character and v.Character.Humanoid then v.Character.Humanoid.MaxHealth=100; end end end end)
for i=t.Value, 1, -1 do t.Value=i; wait(1) end end
while true do initialize() wait(vulnerbilitytime*60) end |
|
|
| Report Abuse |
|
|
L0cky2013
|
  |
| Joined: 30 Jul 2012 |
| Total Posts: 1446 |
|
|
| 13 Aug 2014 08:42 PM |
And there is a small syntax error that was there
local waittime=1--in minutes local vulnerbilitytime=1--in minutes local t=Instance.new("IntValue", Workspace) t.Value=waittime*60; function initialize() game.Players.PlayerAdded:connect(function(p) p.CharacterAdded:connect(function(c) local isActive=t.Value > 0 if isActive then wait(0.5) c:WaitForChild("Humanoid").MaxHealth=math.huge; print(c.Humanoid.MaxHealth) end end) end)
t.Changed:connect(function() if t.Value < 2 then print'less than two doe' for _, v in pairs(game:GetService("Players"):GetPlayers()) do if v.Character and v.Character.Humanoid then v.Character.Humanoid.MaxHealth=100; end end end end)
for i=t.Value, 1, -1 do t.Value=i; wait(1) end end
while true do initialize() wait(vulnerbilitytime*60) end
|
|
|
| Report Abuse |
|
|
|
| 13 Aug 2014 09:03 PM |
| Thanks a ton and it works pretty well except upon death, in vulnerability mode, people gain invincibility again. Any knowledge why? |
|
|
| Report Abuse |
|
|