Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What is wrong with my Payment script?

Something is wrong with it, but I can not figure out what is wrong, nor what the Output means, here is the script;

if script.Parent:FindFirstChild("Accept")and game.Players.LocalPlayer and game.Players.LocalPlayer.Character and game.Players.LocalPlayer:FindFirstChild("PlayerGui")and game.Players.LocalPlayer.PlayerGui:FindFirstChild("Cash")and game.Players.LocalPlayer.PlayerGui.Cash:FindFirstChild("Amount")and game.Players.LocalPlayer.PlayerGui.Cash.Amount:FindFirstChild("AmountMoney")and script:FindFirstChild("Needed")then
script.Parent.Accept.MouseButton1Click:connect(function()
if game.Players.LocalPlayer.PlayerGui.Cash.Amount.AmountMoney>=script.Needed then
script.Parent.Text="Thank you for choosing Equire's"
game.Players.LocalPlayer.PlayerGui.Cash.Amount.AmountMoney=game.Players.LocalPlayer.PlayerGui.Cash.Amount.AmountMoney-script.Needed
wait(2)
script.Parent:Destroy()
elseif game.Players.LocalPlayer.PlayerGui.Cash.Amount.AmountMoney<script.Needed then
script.Parent.Text="You do not have enough money to pay for this"
wait(5)
script.Parent.Text=script.Needed
end end)end

The Output says; Players.Player1.PlayerGui.ScreenGui.Charged.Script:3: attempt to compare two userdata values

1 answer

✓ Accepted answer

It assumed they weren't integers. You need parentheses. Also, I recommend adding '.Value' for IntValues.

if script.Parent:FindFirstChild("Accept")and game.Players.LocalPlayer and game.Players.LocalPlayer.Character and game.Players.LocalPlayer:FindFirstChild("PlayerGui")and game.Players.LocalPlayer.PlayerGui:FindFirstChild("Cash")and game.Players.LocalPlayer.PlayerGui.Cash:FindFirstChild("Amount")and game.Players.LocalPlayer.PlayerGui.Cash.Amount:FindFirstChild("AmountMoney")and script:FindFirstChild("Needed")then
script.Parent.Accept.MouseButton1Click:connect(function()
if (game.Players.LocalPlayer.PlayerGui.Cash.Amount.AmountMoney >= script.Needed) then
script.Parent.Text = "Thank you for choosing Equire's"
game.Players.LocalPlayer.PlayerGui.Cash.Amount.AmountMoney = game.Players.LocalPlayer.PlayerGui.Cash.Amount.AmountMoney - script.Needed.Value
script.Parent:Destroy()
elseif (game.Players.LocalPlayer.PlayerGui.Cash.Amount.AmountMoney < script.Needed) then
script.Parent.Text = "You do not have enough money to pay for this"
wait(5)
script.Parent.Text = script.Needed.Value
end end)end

2 comments

0

Lol, I wonder how I missed that. Thanks man! +1

0

No problem. Mind accepting this answer as well?

This discussion is preserved as it was. New answers, comments, and votes are closed.