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:
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)
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)
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)
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)
I would completely avoid using regular scripts in GUI’s. I recommend you use LocalScripts. Take advantage of the LocalPlayer object and RemoteEvents/RemoteFunctions.