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+=- u gotta use a localscript (i'm dumb)

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?

3 comments

0

Is this is a script or a LocalScript? Make it a LocalScript if not.

0

Guys im an idiot after a bit of research I have deduced that you have to use a localscript

0

add (solved) to the title so it marks as solved.