So i'm making a game, and it requires a GUI to get your data from a folder in serverstorage.
Here is my code: (script in a gui which is in a screengui which is in startergui)
+=-THIS QUESTION HAS ALREADY BEEN SOLVED+=-
wait(0.5) print("hi") local Players = game:GetService("Players") print("hi") local player = Players.LocalPlayer
-- this is the line that gives an error message --
local playername = player.Name
-- this is the line that gives an error message --
print("lonley") while true do print("hiasdwasd") wait() local oxygen = game:GetService("ServerStorage"):WaitForChild("Playerinfo")[playername]:WaitForChild("oxygen") local bar = script.Parent print(playername) oxygen.Changed:Connect(function() bar.Size = UDim2.new((oxygen/100), 0, 0, 15) end)
end
Here is the error message displayed
Players.CHEESEPIZZAPARTYTIME.PlayerGui.ScreenGui.Oxygenindicator.Oxygenbar.Script:6: attempt to index nil with 'Name'
Can someone please tell me why it doesn't work?