So I am trying to make a Leveling System. To gain EXP, you must touch a block. The script is within the Part that needs to be touched. Now, I am getting an error that says ' attempt to index nil with 'LevelsInfo'' The problem is, the script isn't able to find the LevelsInfo which is a Fold with String Values within the Player. I know that I will more than likely have to use a Local Script for this, but why won't it work with a Local Script. If it is possible though to use a normal Script, how would I go about doing that. This is the line that it gets into trouble at 'player.LevelsInfo.Experience.Value += expToGain' Thanks in the long run! -XRangerGuyX
local part = script.Parent local debounce = false`` part.Touched:Connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if not debounce then debounce = true local playersFinished = 0 wait(3) if playersFinished == 0 then print("A Player Has Finished!") local expToGain = 3 playersFinished += 1 player.LevelsInfo.Experience.Value += expToGain elseif playersFinished >= 2 then print("A 2nd Player Has Finished!") local expToGain = 1 player.LevelsInfo.Experience.Value += expToGain end wait(1) debounce = false end end)
Maybe try
player:FindFirstChild("LevelsInfo"):FindFirstChild("Experience").Value +=expToGain
?