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

I dont understand this error attempted to preform arithmetic (mul) on Instance and Number?

Asked by
Nozazxe 107
2 years ago

Hi. So i made a sell script in serverscriptservice and its not working. any idea why?

game.ReplicatedStorage.SellEvent.OnServerEvent:Connect(function(player)

    local leaderstats = player.leaderstats
    local RoCoin = leaderstats["Ro-Coin"]
    local RoBucks = leaderstats.RoBucks
    local Value = leaderstats.RoValue

    RoBucks.Value = RoBucks.Value + RoCoin.Value * Value.Value
    RoCoin.Value = 0
end)
-- above shouldnt be interfereing, the below one is the problem
game.ReplicatedStorage.SellEventDesert.OnServerEvent:Connect(function(player)

    local leaderstats = player.leaderstats
    local RoCoin = leaderstats["Ro-Coin"]
    local RoBucks = leaderstats.RoBucks
    local Value = leaderstats.RoValue
    local selVal = Value *2

    RoBucks.Value = RoBucks.Value + RoCoin.Value * Value.Value 
    RoCoin.Value = 0
end)
0
RoValue is a instance, RoValue.Value is a number. you can't do (object) * 2. NGC4637 602 — 2y
0
arthmetic is math snowpototoy 37 — 2y

1 answer

Log in to vote
1
Answered by
TGazza 1336 Moderation Voter
2 years ago
Edited 2 years ago

The top function looks fine but in your 2nd function you have

    local Value = leaderstats.RoValue
    local selVal = Value *2

that's the cause of the error you're getting.

Change it to

    local Value = leaderstats.RoValue.Value
    local selVal = Value *2

Hope this helps! :)

0
thx sooo much! Nozazxe 107 — 2y
0
No worries! Glad to help! :) TGazza 1336 — 2y
Ad

Answer this question