Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Who doesn't this scrip work?

Asked by 9 years ago

Ok so I have tried to change the script so it would work and I have tried putting it into teams. Here is the script:

01 local playerStats = {} --this keeps a list of the stats for each player that enters the game

02

03

04

05 game.Players.PlayerAdded:connect(function(player)

06

07 local leaderstats = Instance.new("Model", player)

08

09 leaderstats.Name = "leaderstats"

10

11 game.Players.PlayerAdded:connect(function(player)

12

13 local leaderstats = Instance.new("Model", player)

14

15 leaderstats.Name = "leaderstats"

16

17

18

19 local money = Instance.new("IntValue", leaderstats) --We instance a new IntValue as a child of 'leaderstats'

20

21 money.Name = "Money" --this is the name you want the leader-stat to be when it shows up in-game.

22

23 money.Value = 0 --this is the value of money the new player starts out with. To change this, you can add some more code (shown later)

24

25 end)

26

27 local money = Instance.new("IntValue", leaderstats)

28

29 money.Name = "Money"

30

31 money.Value = 0

32

33

34

35 stats[player] = leaderstats

36

37 end)

38

39

40

41 while true do --infinite loop

42

43 for player, stats in ipairs(playerStats) do --loops through each player => stat pair in the table

44

45 players.Money.Value = stats.Money.Value + 1

46

47 end

48

49 wait(5)

50

51 end

52

53 function CheckTeams(player)

54

55 if player.TeamColor == BrickColor.new("Bright red") then

56

57 player.leaderstats.Money.Value = player.leaderstats.Money.Value + 1

58

59 end

60

61 end

Please help, I don't know what's wrong (yes I do have a team that is brick colour ''Bright red'' so it's not because it's for the wrong team.)

Answer this question