vvire
|
  |
| Joined: 14 Feb 2014 |
| Total Posts: 34 |
|
|
| 05 Mar 2014 03:30 PM |
print("Cash Stuffs running!")
function onPlayerEntered(newPlayer) wait(.5) local stats = Instance.new("IntValue") stats.Name = "leaderstats"
stats.Parent = newPlayer
local cash = Instance.new("IntValue")
cash.Name = "Points" cash.Value = 0 --This sets the amount of money every player starts with
cash.Parent = stats
stats.Parent = newPlayer
end
game.Players.ChildAdded:connect(onPlayerEntered)
How do you make it reset when the humanoid dies? |
|
|
| Report Abuse |
|
|
|
| 05 Mar 2014 03:31 PM |
It would go like this pseudocode:
player.CharacterAdded
leaderstat = 0 |
|
|
| Report Abuse |
|
|
vvire
|
  |
| Joined: 14 Feb 2014 |
| Total Posts: 34 |
|
|
| 05 Mar 2014 03:35 PM |
| Isn't player.CharacterAdded meaning when a player joins the game? |
|
|
| Report Abuse |
|
|
|
| 05 Mar 2014 03:36 PM |
Character added is when the players character resets/gets added to the game..
so using your playeradded script,and setting the players values to 0 with characteradded would work |
|
|
| Report Abuse |
|
|
| |
|
vvire
|
  |
| Joined: 14 Feb 2014 |
| Total Posts: 34 |
|
|
| 05 Mar 2014 03:37 PM |
| Tried it, didn't turn out so well... |
|
|
| Report Abuse |
|
|
vvire
|
  |
| Joined: 14 Feb 2014 |
| Total Posts: 34 |
|
|
| 05 Mar 2014 03:39 PM |
@Island, I did add it, but where do I put it?
print("Cash Stuffs running!")
function onPlayerEntered(newPlayer) wait(.5) local stats = Instance.new("IntValue") stats.Name = "leaderstats"
stats.Parent = newPlayer
local cash = Instance.new("IntValue")
cash.Name = "Points" cash.Value = 0
cash.Parent = stats
stats.Parent = newPlayer
end
game.Players.ChildAdded:connect(onPlayerEntered)
|
|
|
| Report Abuse |
|
|
|
| 05 Mar 2014 03:39 PM |
| You tried to learn Lua and it didn't turn out well? |
|
|
| Report Abuse |
|
|
vvire
|
  |
| Joined: 14 Feb 2014 |
| Total Posts: 34 |
|
|
| 05 Mar 2014 03:40 PM |
No, I'd try to make my own scripts, end up getting the whole script with red wiggley lines and errors, I do try to fix scripts when I see them like: Local i is supposed to be: local i |
|
|
| Report Abuse |
|
|
YumERAGON
|
  |
| Joined: 18 Apr 2012 |
| Total Posts: 3893 |
|
| |
|
|
| 05 Mar 2014 03:43 PM |
wow,just wow...
print("Cash Stuffs running!")
function onPlayerEntered(newPlayer) wait(.5) local stats = Instance.new("IntValue") stats.Name = "leaderstats"
stats.Parent = newPlayer
local cash = Instance.new("IntValue")
cash.Name = "Points" cash.Value = 0
cash.Parent = stats
stats.Parent = newPlayer
newPlayer.CharacterAdded:connect(function() for I,v in pairs (plr.leaderstats:GetChildren()) do v.Value = 0 end end) end |
|
|
| Report Abuse |
|
|
|
| 05 Mar 2014 03:44 PM |
oop,not "plr"lol..
just edit it a bit |
|
|
| Report Abuse |
|
|
vvire
|
  |
| Joined: 14 Feb 2014 |
| Total Posts: 34 |
|
| |
|
|
| 05 Mar 2014 03:46 PM |
completely fixed:
print("Cash Stuffs running!")
function onPlayerEntered(newPlayer) wait(.5) local stats = Instance.new("IntValue") stats.Name = "leaderstats"
stats.Parent = newPlayer
local cash = Instance.new("IntValue")
cash.Name = "Points" cash.Value = 0
cash.Parent = stats
stats.Parent = newPlayer
newPlayer.CharacterAdded:connect(function(c) for I,v in pairs (game.Players[c.Name].leaderstats:GetChildren()) do v.Value = 0 end end) end |
|
|
| Report Abuse |
|
|
vvire
|
  |
| Joined: 14 Feb 2014 |
| Total Posts: 34 |
|
|
| 05 Mar 2014 03:48 PM |
I'm sure that it's supposed to work, but when I edited it to that -above- It doesn't recognise, at all. |
|
|
| Report Abuse |
|
|
vvire
|
  |
| Joined: 14 Feb 2014 |
| Total Posts: 34 |
|
| |
|
Azureous
|
  |
| Joined: 29 Jan 2012 |
| Total Posts: 25287 |
|
|
| 05 Mar 2014 03:57 PM |
local function ClearStats(player) player.Character.Humanoid.Died:connect(function() player.leaderstats.Points.Value = 0 end) end
game.Players.PlayerAdded:connect(ClearStats) |
|
|
| Report Abuse |
|
|
vvire
|
  |
| Joined: 14 Feb 2014 |
| Total Posts: 34 |
|
|
| 05 Mar 2014 03:59 PM |
| Sorry, where does this go? |
|
|
| Report Abuse |
|
|
YumERAGON
|
  |
| Joined: 18 Apr 2012 |
| Total Posts: 3893 |
|
| |
|
|
| 05 Mar 2014 04:00 PM |
| Maybe you should read the basics to studio on the wiki then watch the Lua tutorial by roblox on YouTube to try and learn Lua? |
|
|
| Report Abuse |
|
|
vvire
|
  |
| Joined: 14 Feb 2014 |
| Total Posts: 34 |
|
| |
|
vvire
|
  |
| Joined: 14 Feb 2014 |
| Total Posts: 34 |
|
| |
|
wubbzy301
|
  |
| Joined: 15 May 2010 |
| Total Posts: 1188 |
|
|
| 06 Mar 2014 01:07 PM |
function onDied()
backup = leaderstats:Clone() leaderstats:Remove()
backup:Clone().Parent = player end
player.Character.Humanoid.Died:connect(onDied) |
|
|
| Report Abuse |
|
|
vvire
|
  |
| Joined: 14 Feb 2014 |
| Total Posts: 34 |
|
|
| 06 Mar 2014 01:14 PM |
| Is this a seperate script? |
|
|
| Report Abuse |
|
|
wubbzy301
|
  |
| Joined: 15 May 2010 |
| Total Posts: 1188 |
|
|
| 06 Mar 2014 03:09 PM |
function onPlayerEntered(newPlayer) wait(.5) local stats = Instance.new("IntValue") stats.Name = "leaderstats"
stats.Parent = newPlayer
local cash = Instance.new("IntValue")
cash.Name = "Points" cash.Value = 0 --This sets the amount of money every player starts with
cash.Parent = stats
stats.Parent = newPlayer player.Character.Humanoid.Died:connect(function ()
backup = stats:Clone() backup.Points.Value = 0 stats:Remove()
backup:Clone().Parent = newPlayer end)
end
game.Players.ChildAdded:connect(onPlayerEntered) |
|
|
| Report Abuse |
|
|