Attempt to perform arithmetic (add) on number and Vector3

  1. What do you want to achieve?
    The flag to be teleported to the player’s Torso + 0,5,0
  2. What is the issue?
    Whenever run I get this:

Players.captan40000.Backpack.Kalmar Flag.Script:15: attempt to perform arithmetic (add) on number and Vector3

  1. What solutions have you tried so far?
    I can’t find any articles on adding Vector3’s together
script.Parent.Unequipped:Connect(function()
	local ServerStorageService = game:GetService("ServerStorage")
	
	local FlagTool = script.Parent
	local FlagModel = FlagTool.Flag
	local Player = FlagTool.Parent.Parent
	
	repeat
		task.wait()
	until FlagTool.Parent.Name == "Backpack"
	
	FlagModel.Parent = workspace
	FlagTool.Parent = ServerStorageService.DroppedFlags
	
	FlagModel:MoveTo(Player.Character.Torso.Position + 0,5,0)
	
	for index, object in ipairs(FlagModel:GetDescendants()) do
		if object:IsA("BasePart") then
			object.Anchored = false
			object.CanCollide = false
		end
	end
	
	FlagModel.Detection.Touched:Connect(function(otherPart)
		
		local CanContinue = true
		
		for index, object in ipairs(FlagModel:GetDescendants()) do
			if object == otherPart then 
				CanContinue = false
			end
		end
		if CanContinue == true then 
			for index, object in ipairs(FlagModel:GetDescendants()) do
				if object:IsA("BasePart") then
					object.Anchored = true
					object.CanCollide = false
				end
			end
		end
		
	end)
end)

Should be

FlagModel:MoveTo(Player.Character.Torso.Position + Vector3.new(0,5,0))

And ideally it should be a reusable vector so that you don’t have to reconstruct a new one every time, so store it in a variable outside of the connection and reuse it:

local offset = Vector3.new()
script.Parent.Unequipped:Connect(function()
    ...
    FlagModel:MoveTo(Player.Character.Torso.Position + offset)
2 Likes

Doesn’t work. It teleports itself to random places
image

It also breaks the server and client (Above was client, this is server)
image

That’s a different problem. Go create a new thread about it