I'm getting too many complaints on this not working. But I don't know how to fix it, please help?
I have the following code for a currency converter. I use DataStore to save statistics. Could that be why it doesn't work?
button = script.Parent
WhatIHave = script.Parent.Parent.WhatIHave
Estimated = script.Parent.Parent.Estimated.Value
p = game.Players.LocalPlayer
button.MouseButton1Click:connect(function ()
if p.leaderstats.Cash >= WhatIHave.Value then
p.leaderstats.Cash = p.leaderstats.Gems - WhatIHave.Value
p.leaderstats.Diamonds = p.leaderstats.Diamonds + Estimated.Value
repeat
i = 1
script.Parent.Text = "Transaction Complete"
wait(0.5)
script.Parent.Text = ""
i = i+1
until i==5
else
repeat
i = 1
script.Parent.Text = "Insufficient Funds"
wait(0.5)
script.Parent.Text = ""
i = i+1
until i==5
end
end)
The output says attempt to compare number with userdata Line 6. Similar issue when someone buys a developer product. It won't give what they bought.
buybutton = script.Parent
msp = game:GetService("MarketplaceService")
id = 19251902
p = game.Players.LocalPlayer
buybutton.MouseButton1Click:connect(function ()
msp:PromptPruouctPurchase(p,id)
p.leaderstats.Diamonds = p.leaderstats.Diamonds + 10
end)
Output: attempt to perform arithmetic on field 'Diamonds' (a userdata value) Line 7
I need to fix this as soon as possible, as this is causing mayhem on my game.
Everything is in a LocalScript

1 comment
Got it. Thanks!