Invalid argument #2 (string expected, got Instance)

  1. What do you want to achieve?
    I want an object to to tween shortly after a remote event is fired.

  2. What is the issue? Include screenshots / videos if possible!
    I don’t understand why I’m getting this error.

  3. What solutions have you tried so far?
    I’ve looked on the dev forum for solutions, but none exist.

left.OnServerEvent:Connect(function(plr, pow)
	local info =, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
	if tool:FindFirstChild("WeldConstraint") and db then
		local p = {"A", "B"} -- These gets overwritten into the part names.
		local Des = game.Workspace.BallPositions:GetDescendants()
		for i, v in pairs(Des) do
			if v:isA("BasePart") then
				p[i] = v
		haveBall.Value = false
		db = false
		for i, v in pairs(p) do
			-- The Problem Code (start) --
			local part = ballPosition[p[i]]
			-- The Problem Code (end) --
			local Tween1 = TS:Create(part, info, ballPosition[p[i + 1]].Position)
	db = true

Anything Helps.

1 Like

I dont know, but maybe the problem lays in the goal of the tween, I usually do:

local goal = {Position = ballPosition[p[i + 1]].Position}
local Tween1 = TS:Create(part, info, goal)

Tell me if this makes the change :smiley:

Sadly it did not. Thank you for trying though.

I may have found the problem in the code, but I’m still getting the same error. I’ve tried to change it to ballPosition[p[i].Position]
but then it says, Invalid Argument #2, string expected, got Vector3
Aren’t I supposed to be able to assign anything I want to a variable?

This piece of code assigns instances as the values in the table. Your comment says that you expect part names so you should just do p[i] = v.Name in that loop that assigns the new values. Another option is just to do p[i].Name whenever accessing. You should also note that in your loop p[i + 1] will eventually yield nil.

1 Like