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

Script saying there is a 'nil' value in this script, can someone help?

Asked by
RGRage 45
8 years ago

I am trying to create a script that makes a data storage for a player when he/she joins the game and update their health every second inside another IntValue, but the script is saying that there is a 'nil' value in the script.

01local plr = game.Players.LocalPlayer
02 
03 
04plr.CharacterAdded:connect(function(char)
05    local Humanoid = char:WaitForChild('Humanoid')
06    local plrName = plr.Name
07    local PlayerData = game.ServerStorage.PlayerNameStorage:WaitForChild(plrName.."Data")
08    local PlayerNameValue = PlayerData:WaitForChild(plrName.."NameValue")
09    local HealthIntValue = PlayerData:WaitForChild(plrName.."HealthValue")
10    local MaxHealthIntValue =PlayerData:WaitForChild(plrName.."MaxHealthValue")
11    while true do
12        if plr ~= nil then
13            if char ~= nil then
14                if Humanoid ~= nil then
15                    if Humanoid.Health > 0 then
View all 32 lines...

Here is the whole code:

01game.Players.PlayerAdded:connect(function(plr)
02    local plrName = plr.Name
03    if game.ServerStorage.PlayerNameStorage ~= nil then
04        local PlayerData = Instance.new('Folder')
05        PlayerData.Parent = game.ServerStorage.PlayerNameStorage
06        PlayerData.Name = plrName.."Data"
07        local PlayerNameValue = Instance.new('StringValue')
08        PlayerNameValue.Parent = PlayerData
09        PlayerNameValue.Name = plrName.."NameValue"
10        PlayerNameValue.Value = plrName
11        local HealthIntValue = Instance.new('IntValue')
12        HealthIntValue.Parent = PlayerData
13        HealthIntValue.Name = plrName.."HealthValue"
14        local MaxHealthIntValue = Instance.new('IntValue')     
15        MaxHealthIntValue.Name = plrName.."MaxHealthValue"
View all 67 lines...
2
You're trying to access ServerStorage on the client. You can't do that. 1waffle1 2908 — 8y

Answer this question