So UpgradeWeapon is a stringvalue and this is my script in serverscriptservice. Why does it return this error? How can I access the part?
ServerScriptService.Upgrade Handler.Main:12: invalid argument #2 (string expected, got Instance)
local ReplicatedStorage = game:GetService("ReplicatedStorage") local remoteEvent = ReplicatedStorage:WaitForChild("UpgradeEvent") local function upgrade(player,UpgradeWeapon,UpgradeAmount) local Weapon = UpgradeWeapon print ("Upgrade Event Recieved") player.Inventory[Weapon].Damage.Value = player.Inventory[UpgradeWeapon].Damage.Value + UpgradeAmount end remoteEvent.OnServerEvent:Connect(upgrade)
try changing
player.Inventory[Weapon].Damage.Value = player.Inventory[UpgradeWeapon].Damage.Value + UpgradeAmount
to
player.Inventory[Weapon].Damage.Value = player.Inventory[UpgradeWeapon].Damage.Value + UpgradeAmount.Value
the error is in line 12, and it is happening because you're giving an instance not a string
-- Pretty sure you are firing the actual tool instead of the name of the tool. try local Weapon = tostring(UpgradeWeapon) player.Inventory[Weapon].Damage.Value += tonumber(UpgradeAmount)