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 » Scripting Helpers
Home Search
 

Re: Im sick of trying to figure it out, can you help me?

Previous Thread :: Next Thread 
kingmatt2 is not online. 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 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
06 Jun 2013 06:10 PM
...
Report Abuse
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
06 Jun 2013 06:27 PM
Is everyone stupid or lazy? Or both?
Report Abuse
PerpetualMovement is not online. PerpetualMovement
Joined: 04 Dec 2012
Total Posts: 1001
06 Jun 2013 06:29 PM
Both
Report Abuse
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
06 Jun 2013 06:56 PM
Ha Ha Ha..
Report Abuse
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
06 Jun 2013 07:01 PM
BUMP.
Report Abuse
killjoy37 is not online. 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 is not online. 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 is not online. 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 is not online. killjoy37
Joined: 27 Aug 2008
Total Posts: 2821
06 Jun 2013 07:16 PM
Correctamundo
Report Abuse
Desperian is not online. 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 is not online. 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
GuestCapone is not online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
06 Jun 2013 08:21 PM
Lemme see...
Report Abuse
kingmatt2 is not online. 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
GuestCapone is not online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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