Why am I getting this error?

Im trying to make a clickable UI Object that will add amounts of value that will represent the recourses you have, why am I getting this error?

  11:40:55.217  Players.NubblyFry.PlayerGui.MainGui.ScrollingFrame.Bronze Cork Screw.AddVal:10: attempt to perform arithmetic (mul) on Instance  -  Client - AddVal:10
  11:40:55.218  Stack Begin  -  Studio
  11:40:55.218  Script 'Players.NubblyFry.PlayerGui.MainGui.ScrollingFrame.Bronze Cork Screw.AddVal', Line 10  -  Studio - AddVal:10
  11:40:55.219  Stack End  -  Studio


local cooldown = false

local Amount = script.Parent:WaitForChild("Amount")

local Multiplier = game:GetService("ReplicatedStorage"):WaitForChild("Values").Multiplier

	if cooldown == false then
		cooldown = true
		Amount = Amount * Multiplier
		cooldown = false

Line 10 ( 	Amount = Amount * Multiplier )

You are trying to multiply two instances, I think what you meant to do is to multiply the .Value properties of two ValueBase instances.

So you should type Amount.Value *= Multiplier.Value instead.

I assume these values are int values right? if it is then:

Amount.Value *= Multiplier.Value

What does *= mean?

The multiplier value is a Number value, I wanted it to sometimes deposit decimals.

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Multiplier = ReplicatedStorage:WaitForChild("Values").Multiplier
local Button = script.Parent
local Amount = Button:WaitForChild("Amount")

local Cooldown = false

	if not Cooldown then
		Cooldown = true
		Amount.Value *= Multiplier.Value
		Cooldown = false

Can you explain your exact Solution to the error?

You forgot to reference the value, you only referenced the actual value instance in your code.

Why did you put *= and remove Amount = ?

Amount.Value *= Multiplier.Value is a shortened version of Amount.Value = Amount.Value * Multiplier.Value as they both do the exact same thing but I just prefer the first one as it looks nicer.

1 Like