[UNSOLVED] Help with a Huge Script (2)?
So instead of editing my last thread, I just decided to put it into a new Question because I changed it so much. It still doesn't work, but it's a lot cleaner, and in two scripts now.
So, if you didn't see the last thread, I'm trying to script an RPG game. I want it so that when a player connects, a function assigns a bunch of BoolValues and NumberValues to represent Experience, Levels, HP, etc. Whenever I test it, it gives me in the output "Gold is not a valid member of Player", "Gems is not a valid member of Player" etc, for each of the Values, and I'm not sure what I did wrong. Here's the code:
03 | Gold = Instance.new( "NumberValue" ) |
04 | Gems = Instance.new( "NumberValue" ) |
05 | PlayerLevel = Instance.new( "NumberValue" ) |
06 | Exp = Instance.new( "NumberValue" ) |
07 | HP = Instance.new( "NumberValue" ) |
08 | Quest 1 = Instance.new( "BoolValue" ) |
09 | Quest 2 = Instance.new( "BoolValue" ) |
10 | Quest 3 = Instance.new( "BoolValue" ) |
11 | Quest 4 = Instance.new( "BoolValue" ) |
12 | Quest 5 = Instance.new( "BoolValue" ) |
13 | Player = game.Players.LocalPlayer |
19 | ScreenGui = game.StarterGui.ScreenGui |
20 | ShopBG = ScreenGui.ShopBG |
21 | QuestsBG = ScreenGui.QuestsBG |
22 | StatsBG = ScreenGui.StatsBG |
23 | OptionsBG = ScreenGui.OptionsBG |
29 | a = game.Players.LocalPlayer:GetChildren() |
31 | function assignValues() |
32 | repeat wait() until Player |
34 | if v:IsA( "BoolValue" or "NumberValue" ) then |
35 | Player.MaxHealth = Player.HP.Value |
44 | PlayerLevel.Parent = Player |
45 | PlayerLevel.Name = "PlayerLevel" |
51 | Quest 1. Parent = Player |
52 | Quest 1. Name = "Quest1" |
54 | Quest 2. Parent = Player |
55 | Quest 2. Name = "Quest2" |
57 | Quest 3. Parent = Player |
58 | Quest 3. Name = "Quest3" |
60 | Quest 4. Parent = Player |
61 | Quest 4. Name = "Quest4" |
63 | Quest 5. Parent = Player |
64 | Quest 5. Name = "Quest5" |
72 | game.Players.PlayerAdded:connect(assignValues) |
There is another script that assigns XP and Levels up the Player. I'm not sure if you need to see that too, but I'll include the code:
03 | Gold = Instance.new( "NumberValue" ) |
04 | Gems = Instance.new( "NumberValue" ) |
05 | PlayerLevel = Instance.new( "NumberValue" ) |
06 | Exp = Instance.new( "NumberValue" ) |
07 | HP = Instance.new( "NumberValue" ) |
08 | Quest 1 = Instance.new( "BoolValue" ) |
09 | Quest 2 = Instance.new( "BoolValue" ) |
10 | Quest 3 = Instance.new( "BoolValue" ) |
11 | Quest 4 = Instance.new( "BoolValue" ) |
12 | Quest 5 = Instance.new( "BoolValue" ) |
13 | Player = game.Players.LocalPlayer |
19 | ScreenGui = game.StarterGui.ScreenGui |
20 | ShopBG = ScreenGui.ShopBG |
21 | QuestsBG = ScreenGui.QuestsBG |
22 | StatsBG = ScreenGui.StatsBG |
23 | OptionsBG = ScreenGui.OptionsBG |
30 | local xps = { 0 , 100 , 300 , 600 , 1000 , 1500 , 2000 , 2500 , 3000 , 4000 , 5000 , 6500 , 8000 , 9500 , 11000 , 12500 , 14000 , 15500 , 18000 , 21000 , 25000 , 30000 , 35000 , 40000 , 45000 , 50000 , 57500 , 65000 , 72500 , 82500 , 100000 } ; |
31 | local xp = Player.Exp.Value; |
33 | while xps [ level ] and xps [ level ] < = xp do |
37 | Player.HP.Value = 200 + 100 * Player.PlayerLevel.Value; |