kingmatt2
|
  |
| Joined: 20 Aug 2011 |
| Total Posts: 6494 |
|
|
| 06 Jun 2013 06:03 PM |
I do admit that this is a *BROKEN* Free modal.
It has no output, but it doeset make any stats in the player. Im not talking about stats that you can see. I need stats that are in the player and other scripts inside the player can use them, like a hunger/thirst script just like this one is! So I've spent about a half hour trying to fix this and I dident fix it.
function modStat(stat, val) stat.Value = stat.Value + val
if stat.Value > 100 then stat.Value = 100 end end
function checkDead(statTable) for index, child in pairs(statTable) do if child.Value < 1 then return true end end
return false end
function resetStats(statTable) for index, child in pairs(statTable) do child.Value = 100 end end
game.Players.ChildAdded:connect(function(player) local stats = Instance.new("IntValue") stats.Name = "Stats"
local hunger = Instance.new("IntValue") hunger.Name = "Hunger" hunger.Value = 100 hunger.Parent = stats
local thirst = Instance.new("IntValue") thirst.Name = "Thirst" thirst.Value = 100 thirst.Parent = stats
local health = Instance.new("IntValue") health.Name = "Health" health.Value = 100 health.Parent = stats
stats.Parent = player
local allStats = {hunger, thirst, health}
while true do modStat(hunger, -1) modStat(thirst, -1) modStat(health, 1)
wait(15)
local char = player.Character local torso = char:findFirstChild("Torso")
if torso ~= nil then if torso.Position.y < 24.5 then modStat(health, -50) end end
if checkDead(allStats) then local humanoid = char.Humanoid
humanoid.Health = 0
resetStats(allStats) end end end) |
|
|
| Report Abuse |
|
|
kingmatt2
|
  |
| Joined: 20 Aug 2011 |
| Total Posts: 6494 |
|
| |
|
kingmatt2
|
  |
| Joined: 20 Aug 2011 |
| Total Posts: 6494 |
|
|
| 06 Jun 2013 06:27 PM |
| Is everyone stupid or lazy? Or both? |
|
|
| Report Abuse |
|
|
| |
|
kingmatt2
|
  |
| Joined: 20 Aug 2011 |
| Total Posts: 6494 |
|
| |
|
kingmatt2
|
  |
| Joined: 20 Aug 2011 |
| Total Posts: 6494 |
|
| |
|
killjoy37
|
  |
| Joined: 27 Aug 2008 |
| Total Posts: 2821 |
|
|
| 06 Jun 2013 07:03 PM |
| Maybe they just read really slowly, your script isn't exactly short. |
|
|
| Report Abuse |
|
|
killjoy37
|
  |
| Joined: 27 Aug 2008 |
| Total Posts: 2821 |
|
|
| 06 Jun 2013 07:09 PM |
If you are testing this in Play Solo, it won't work because Player.PlayerAdded doesn't work in Play Solo, try Test > Start Server then a screen will come up, then in that screen do Test > Start Player Everything to the output will be shown on that first screen that you created, the Server, so check it for errors, and the Player you added you can test things out with. |
|
|
| Report Abuse |
|
|
kingmatt2
|
  |
| Joined: 20 Aug 2011 |
| Total Posts: 6494 |
|
|
| 06 Jun 2013 07:10 PM |
| So your saying that it will work in normal mode. But not in test? |
|
|
| Report Abuse |
|
|
killjoy37
|
  |
| Joined: 27 Aug 2008 |
| Total Posts: 2821 |
|
| |
|
Desperian
|
  |
| Joined: 07 Feb 2012 |
| Total Posts: 3371 |
|
|
| 06 Jun 2013 07:18 PM |
Yes, it'd work fine online bar the loop. The loop would mean that the function wouldn't end, so therefore it wouldn't do what you wanted for the next player, if that makes sense. I would post a script with a coroutine, but apparently it's against the rules, so I'll post the last segment, I'm sure you'll be able to replace this part of the code correctly.
coroutine.resume(coroutine.create(function() while true do wait(15) modStat(hunger, -1) modStat(thirst, -1) modStat(health, 1) local char = player.Character local torso = char:findFirstChild("Torso") if char ~= nil and torso ~= nil then if torso.Position.y < 24.5 then modStat(health, -50) end end if checkDead(allStats) then local humanoid = char.Humanoid humanoid.Health = 0 resetStats(allStats) end end end)) end) -- Last end on your original script posted. |
|
|
| Report Abuse |
|
|
kingmatt2
|
  |
| Joined: 20 Aug 2011 |
| Total Posts: 6494 |
|
|
| 06 Jun 2013 07:27 PM |
Okay thanks for the help, I havent tested it yet, but before I do can you tell me whats wrong with this?
local targ = mouse.Target
if targ.Parent.ClassName == Model then do not |
|
|
| Report Abuse |
|
|
| |
|
kingmatt2
|
  |
| Joined: 20 Aug 2011 |
| Total Posts: 6494 |
|
|
| 06 Jun 2013 08:23 PM |
| It still doesent work, but the second script I said I fixed. |
|
|
| Report Abuse |
|
|
|
| 06 Jun 2013 09:57 PM |
| Matt your problem in the first script is the loop part, I tested it without the loop and it worked fine.. |
|
|
| Report Abuse |
|
|