Attempt to index nil with 'data' When making a script | Support Needed~!

Hello, so I am making a bank system and need a verify that someone has the money they can get,
When I click the withdraw button it gives me this error:

Script:

local waitt = 5

local Player1 = script.Parent.Parent.Parent.PlayerName.Value
local Player = game.Players:WaitForChild(Player1, waitt)
local Amount = script.Parent.Parent.Amount.Text

script.Parent.MouseButton1Click:Connect(function()
if Player.data.Checkings.Value <= 0 then return
end
if Player.data.Checkings.Value > 0 and Player.data.Checkings.Value >= Amount then
Player.data.Checkings.Value = - Amount
end
end)

it seems like “Player” is nil, can you show us the explorer

Here, the GUI.

When you click on a click detector it gives the gui and changes the Name and ID to yours.

Show us what each player has inside of them once they join the game

try this

script.Parent.MouseButton1Click:Connect(function()
   local Player1 = script.Parent.Parent.Parent.PlayerName.Value
   local Player = game.Players:WaitForChild(Player1)
   local Amount = script.Parent.Parent.Amount.Text
   
   if Player.data.Checkings.Value <= 0 then return end
   if Player.data.Checkings.Value > 0 and Player.data.Checkings.Value >= Amount then
      Player.data.Checkings.Value = - Amount
   end
end)

the code won’t detect the change so try it

It doesn’t give an error but now doesn’t do a thing

Try the following code:

script.Parent.MouseButton1Click:Connect(function()
   local Player1 = script.Parent.Parent.Parent.PlayerName.Value
   local Player = game:GetService("Players"):FindFirstChild(Player1)
   local Amount = script.Parent.Parent.Amount.Text
   
   if Player and Player.data.Checkings.Value <= 0 then 
     return 
   end
   if Player and Player.data.Checkings.Value > 0 and Player.data.Checkings.Value >= Amount then
      Player.data.Checkings.Value = -tonumber(Amount)
   end
end)

It still isn’t doing anything I have no Idea why.

Are you sure that your if statements are in correct form?

Yep doubled checked it I am sure!

maybe convert the string to a number first?

script.Parent.MouseButton1Click:Connect(function()
   local Player1 = script.Parent.Parent.Parent.PlayerName.Value
   local Player = game.Players:WaitForChild(Player1)
   local Amount = script.Parent.Parent.Amount.Text
   
   if Player.data.Checkings.Value <= 0 then return end
   if Player.data.Checkings.Value > 0 and Player.data.Checkings.Value >= tonumber(Amount) then
      Player.data.Checkings.Value = - tonumber(Amount)
   end
end)

also can we see the text? (tonumber() will return nil if there’s anything that’s not a number in the string, it doesn’t matter if there’s a number in it)

Still not I need to see if I can do something without just 1 script.

I would completely avoid using regular scripts in GUI’s. I recommend you use LocalScripts. Take advantage of the LocalPlayer object and RemoteEvents/RemoteFunctions.