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

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

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)

2 comments

0

RoValue is a instance, RoValue.Value is a number. you can't do (object) * 2.

0

arthmetic is math

1 answer

✓ Accepted answer

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! :)

2 comments

0

thx sooo much!

0

No worries! Glad to help! :)

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