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

Confusing error, help please? [SOLVED] [closed]

Asked by 10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

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

Locked by TheMyrco

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

2 answers

Log in to vote
1
Answered by
Lacryma 548 Moderation Voter
10 years ago
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.Value >= WhatIHave.Value then
        p.leaderstats.Cash.Value = p.leaderstats.Gems.Value - WhatIHave.Value
        p.leaderstats.Diamonds.Value = p.leaderstats.Diamonds.Value + 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)
buybutton = script.Parent
msp = game:GetService("MarketplaceService")
id = 19251902
p = game.Players.LocalPlayer
buybutton.MouseButton1Click:connect(function()
    msp:PromptProductPurchase(p, id)
    p.leaderstats.Diamonds.Value = p.leaderstats.Diamonds.Value + 10
end)
0
Got it. Thanks! fahmisack123 385 — 10y
Ad
Log in to vote
-1
Answered by 10 years ago

Hmmm im not to sure i will give it a secound and ill see

0
Please do. I really need this help :D fahmisack123 385 — 10y