|
local Players = game.Players:GetPlayers()
local Hunger = Instance.new("IntValue", Players)
Hunger.name = Hunger
Hunger.Value = 100
while true do
wait(60)
Hunger.Value = -10
end
in a local script
I cant use it on multiple people right now |
|
Alend43Join Date: 2013-11-13 Post Count: 451 |
You have to clone the IntValue |
|
AtchechJoin Date: 2014-07-04 Post Count: 173 |
you want it to degrade -10 every 60 seconds?
|
|
|
wait i did a little fixing
local Players = game.Players:GetChildren()
local Hunger = Instance.new("IntValue")
Hunger.Parent = Players
Hunger.name = Hunger
Hunger.Value = 100
while true do
wait(60)
Hunger.Value = -5
end
It still doesn't work, help please!! |
|
imepic457Join Date: 2012-12-21 Post Count: 212 |
i think putting the value into players wont work
since its a local script you can do local player = game.Players.LocalPlayer then you got to change the parent of Hunger to player |
|
AtchechJoin Date: 2014-07-04 Post Count: 173 |
Hunger.Value = Hunger.Value -5 *
|
|
|
I don't understand why you're asking that question. You should be testing it yourself to see if your code works. If it doesn't, then you ask for help. |
|
dj7679Join Date: 2013-06-11 Post Count: 307 |
What are you trying to do ? |
|
imepic457Join Date: 2012-12-21 Post Count: 212 |
@cheeto i guess he worded it wrong because he said "it still wont work" |
|
|
OK this is a reply to your updated code.
First, the it's Hunger.Name, not Hunger.name.
Second, the code doesn't work because you are only creating one instance.
Third, you have to cycle through the variable Players by using a for _,v in pairs function.
|
|
|
i dont understand what you mean by only one instance?
And i dont know how to do the for i,v in pairs for players :/
|
|
ZuedJoin Date: 2015-05-18 Post Count: 506 |
local Players = game.Players:GetChildren()
local Hunger = Instance.new("IntValue")
Hunger.Parent = game.Players.LocalPlayer
Hunger.Name = "Hunger"
Hunger.Value = 100
while true do
wait(60)
Hunger.Value = Hunger.Value - 5
end
|
|
|
http://wiki.roblox.com/index.php?title=Global_namespace/Basic_functions&redirect=no#pairs
I, v in pairs basically loops through the values of a table.
Here's an example:
Players = game.Players:GetPlayers()
for i, v in pairs(Players) do
-- code here
end |
|
Em_ilyJoin Date: 2014-01-21 Post Count: 1708 |
For i,v in pairs is a loop that goes over a set number of parts.
I = Index (Basically it's one in this case)
V = Value (Of whatever you're looping)
For example:
for i,v in pairs(game.Players:GetPlayers()) do
v.Character.Humanoid:BreakJoints()
end
^ It would grab all the players, and break their joints. What is beside pairs is the value, but in most instances you must use a table to define what is after pairs like:
local tab = {game.workspace, game.Players:GetPlayers(), true}
[Just an example ^] |
|
ZuedJoin Date: 2015-05-18 Post Count: 506 |
local Players = game.Players:GetChildren()
local Hunger = Instance.new("IntValue")
Hunger.Parent = game.Players.LocalPlayer
Hunger.Name = "Hunger"
Hunger.Value = 100
while true do
wait(60)
Hunger.Value = Hunger.Value - 5
end
|
|
|
Use Zued's code if you're planning to do this in a local script.
Otherwise, use for i,v in pairs if you're doing this in a server script. |
|