Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

What is wrong with my Payment script?

Asked by 9 years ago

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

Log in to vote
1
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

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

0
Lol, I wonder how I missed that. Thanks man! +1 TheeDeathCaster 2368 — 9y
0
No problem. Mind accepting this answer as well? Shawnyg 4330 — 9y
Ad

Answer this question